'Facebook like', 'twitter'=>'Twitter', 'Google_plusone'=>'Google PlusOne' ); $out = ''; if( isset($_POST['simple_share_position'])) { $option = array(); //print_r($_POST); $option['auto'] = (isset($_POST['simple_share_auto_display']) and $_POST['simple_share_auto_display']=='on') ? true : false; //echo $option['auto']; foreach (array_keys($active_buttons) as $item) { $option['active_buttons'][$item] = (isset($_POST['simple_share_active_'.$item]) and $_POST['simple_share_active_'.$item]=='on') ? true : false; } $option['jsload'] = (isset($_POST['simple_share_javascript_load']) and $_POST['simple_share_javascript_load']=='on') ? true : false; $option['twitter_id'] = esc_html($_POST['simple_share_twitter_id']); //print_r($option); update_option('simple_share', $option); // Put a settings updated message on the screen $out .= '

'.__('Settings saved.', 'menu-test' ).'

'; } //GET ARRAY OF STORED VALUES $option = simple_share_get_options_stored(); $auto = ($option['auto']) ? 'checked="checked"' : ''; $jsload = ($option['jsload']) ? 'checked="checked"' : ''; $out .= '

'.__( 'Facebook and Twitter share buttons', 'menu-test' ).'

'.__("General options", 'menu-test' ).'

'; $out .='
'.__("Auto Display", 'menu-test' ).': '.__("Enable Auto display of Social Share buttons on Home Page", 'menu-test' ).'
'.__("Code for Manual Display", 'menu-test' ).': <?php if(function_exists('simple_add_social_share')) simple_add_social_share(); ?>
'.__("Active share buttons", 'menu-test' ).': '; foreach ($active_buttons as $name => $text) { $checked = ($option['active_buttons'][$name]) ? 'checked="checked"' : ''; $out .= '
' . __($text, 'menu-test' ).'   
'; } $out .= '
'.__("Load Javascript in Footer", 'menu-test' ).': '.__("(Recommended, else loaded in header)", 'menu-test' ).'
'.__("Your Twitter ID", 'menu-test' ).': '.__("Specify your twitter id without @", 'menu-test' ).'

'; echo $out; } // PRIVATE FUNCTIONS function simple_share_get_options_stored() { //GET ARRAY OF STORED VALUES $option = get_option('simple_share'); if ($option===false) { //OPTION NOT IN DATABASE, SO WE INSERT DEFAULT VALUES $option = simple_share_get_options_default(); add_option('simple_share', $option); } else if(!is_array($option)) { // Versions below 1.2.2 compatibility $option = json_decode($option, true); } // Versions below 1.5.1 compatibility if (!isset($option['auto'])) { $option['auto'] = true; } // Versions below 1.4.1 compatibility if (!isset($option['jsload'])) { $option['jsload'] = true; } return $option; } function simple_share_get_options_default () { $option = array(); $option['auto'] = true; $option['active_buttons'] = array('facebook_like'=>true,'twitter'=>true,'Google_plusone'=>true); $option['jsload'] = true; return $option; } ?>