File: /var/www/html/wp-content/plugins/froged/froged-admin.php
<?php
if(!defined('ABSPATH')) exit;
add_action( 'admin_menu', 'froged_woo_menu');
function froged_woo_menu() {add_options_page('Froged', 'Froged','manage_options', 'froged', 'froged_woo_conf');}
function froged_woo_conf() {
?>
<style>
#wrap{margin:0; padding:0;}
#col1{width:600px;float:left;text-align:left;padding:0 0 0 10px; margin: 0 10px 0 0}
#col2{width:170px;float:left;text-align:right;padding:0 10px 0 0}
#col3{width:790px;clear:both; margin:20px 0;border-bottom:1px solid #ccc;font-size:20px;padding:0 0 10px 10px}
#save{width:800px;clear:both; margin:20px 0}
.instruccion{ font-style:italic; font-size:13px;color:#888; margin:12px 0 0 0}
@media screen and (max-width: 899px) {
#col1{width:500px}
#col2{width:170px}
#col3{width:690px}
#save{width:700px}
}
@media screen and (max-width: 767px) {
#col1{width:450px}
#col2{width:170px}
#col3{width:640px}
#save{width:650px}
}
@media screen and (max-width: 479px) {
#col1{width:170px}
#col2{width:150px}
#col3{width:340px}
#save{width:350px}
}
</style>
<div class="wrap">
<h2>Froged</h2>
<form method="post" action='options.php' id="save">
<?php settings_fields('froged_woo_options'); ?>
<?php do_settings_sections('froged_events'); ?>
<input class="button-primary" type="submit" name="submit" value="save changes" style="margin:20px 0 0 20px" />
</form>
</div>
<?php
}
add_action('admin_init', 'froged_woo_admin_init');
function froged_woo_admin_init() {
register_setting('froged_woo_options','froged_woo_options','froged_woo_validate');
add_settings_section('froged_woo_main','', 'froged_woo_section_text','froged_events');
add_settings_field('froged_woo_id_', '','froged_woo_conf_id_input','froged_events','froged_woo_main');
add_settings_field('froged_woo_inc', '','froged_woo_conf_inc_input','froged_events','froged_woo_main');
add_settings_field('froged_woo_ref', '','froged_woo_conf_ref_input','froged_events','froged_woo_main');
}
/* DOCUMENTATION */
function froged_woo_section_text() {
echo "<a href='https://app.froged.com/?utm_source=wordpress_plugin' target='_blank'>Plugin documentation</a>";
}
/* ID Froged */
function froged_woo_conf_id_input() {
$options = get_option('froged_woo_options');
$id = $options['id'];
echo "<div id='col3'>Configuration</div>";
echo "<div id='col1'><label>WORKSPACE ID</label>
<div class='instruccion'>Enter your WORKSPACE ID and click Save. <a href='https://app.froged.com/in/settings/info' target='_blank'>How to get your WORKSPACE ID and configure your module?</a></div></div>";
echo "<div id='col2'><input id='id' name='froged_woo_options[id]' type='text' value='$id' /></div>";
}
/* Activate */
function froged_woo_conf_inc_input() {
$options = get_option('froged_woo_options');
$id = $options['include_snippet'];
echo "<div id='col1'><label>Active</label><br />
<div class='instruccion'>If this box is not checked, The Froged widget will not be displayed and events will not be tracked.</div></div>";
echo "<div id='col2'><input name='froged_woo_options[include_snippet]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></div>";
}
/* PRODUCT REF */
function froged_woo_conf_ref_input() {
$options = get_option('froged_woo_options');
$id = $options['product_ref'];
echo "<div id='col3'>Woocommerce only</div>";
echo "<div id='col1'><label><strong>Product identifier</strong></label>
<div class='instruccion'>You can identify the product reference using the Wordpress ID or the SKU you have defined.</div></div>";
echo "<div id='col2'><select name='froged_woo_options[product_ref]'>
<option value='0' " . selected( $id , 0,false) . ">SKU</option>
<option value='1' " . selected( $id , 1,false) . ">ID Product</option>
</div>";
}
/* save OPTIONS */
function froged_woo_validate($form){
$options = get_option('froged_woo_options');
$updated = $options;
$updated['id'] = $form['id'];
$updated['include_snippet'] = $form['include_snippet'];
$updated['product_ref'] = $form['product_ref'];
$updated['taxes'] = 1;
return $updated;
}
?>