コード例 #1
0
 function set_settings()
 {
     /* Additional option entries in db you intend to use. Assign settings to these options manually if you want. If not it'll be automatically read from /includes/settings/ . Ex: $add_options = array("demo_settings") will read /includes/settings/demo_settings.php unless its specifically assigned like so: array("demo_settings" => "my_demo_settings") in which case it will read /includes/settings/demo_settings.php instead.;*/
     // Get option arrays from setting-* files. Every file will be a section.
     $full_settings_arr = Skeleteon_Generic::get_settings_from_files();
     // update $options var in main plugin class
     var_dump($full_settings_arr);
     Skeleteon_Generic::upd_plug_var('options', $full_settings_arr);
     // Get options option key
     $vars = Skeleteon_Generic::get_plug_vars();
     var_dump($vars['add_options']);
     $optk = $vars['plug_opt'];
     // add sections. add_settings_section( $id, $title, $callback, $page );
     foreach ($full_settings_arr as $sect_k => $settings) {
         add_settings_section($sect_k, ucfirst($sect_k), array($this, 'section_head'), $vars['plug_slug']);
         // add settings. add_settings_field( $id, $title, $callback, $page, $section, $args );
         foreach ($settings as $ik => $setting) {
             // ignore if the option doesnt have a unique_key, which means its not an actual option but a layout helper like gr_start.
             if (is_int($ik) || array_key_exists('type', $setting) && $setting['type'] == 'togglebox_start') {
                 continue;
             }
             $args = array('key' => $ik, 'args' => $setting, 'r' => false);
             // True if we are going to display the fields in a custom style, or false if we are going to use default do_settings_sections() function
             $custom_display = false;
             if ($custom_display) {
                 $cb = '__return_false';
                 $args = array();
             } else {
                 $cb = array($this, 'gen_setting');
             }
             add_settings_field($ik, $setting['label'], $cb, $vars['plug_slug'], $sect_k, $args);
         }
     }
 }
コード例 #2
0
 public static function gen_images_arr_from_folder($dir, $none = true, $basedir = '', $baseuri = '', $vars)
 {
     //	if(empty($basedir) ) $basedir = Skeleteon_Generic::get_plug_var('plug_dir');
     if (empty($vars)) {
         $vars = Skeleteon_Generic::get_plug_vars();
     } else {
         if (empty($basedir)) {
             $basedir = $vars['plug_dir'];
         }
         if (empty($baseuri)) {
             $baseuri = $vars['plug_uri'];
         }
     }
     $imgList = array();
     $imgdir = $basedir . $dir;
     if ($handle = opendir($imgdir)) {
         while (false !== ($file = readdir($handle))) {
             //	var_dump($file);
             if ($file != "." && $file != "..") {
                 $name = substr($file, 0, strlen($file) - 4);
                 $img = $baseuri . $dir . $file;
                 $imgList[$name] = $img;
                 //		var_dump($thumb,$bgname);
             }
         }
         if ($none) {
             $tmp = array('none' => $baseuri . 'rsc/img/' . 'none.jpg');
             //		$temp = array('none' => $imgList['none']);
             //		unset($imgList['none']);
             $imgList = $tmp + $imgList;
         }
         closedir($handle);
     }
     return $imgList;
 }
コード例 #3
0
 public function __construct()
 {
     self::$vars = Skeleteon_Generic::get_plug_vars();
     add_action('wp_loaded', array($this, 'scriptsRegister'));
     $admin_ajax_actions = array();
     // ajax hooks
     //add_action('wp_ajax_eot_bsw_theme_check', 'eot_get_bsw_themes');
     //	add_action('wp_ajax_eot_gwf_check', 'eot_google_font_check');
     //	add_action('wp_ajax_eot_js_opt_check', 'eot_opt_check_js');
     add_action("wp_ajax_ske_get_gwf_variant", array($this, "get_gwf_variant"));
     //		add_action( "wp_ajax_nopriv_{$this->name}_action", array( $this, 'ajaxCb' ) );
 }
コード例 #4
0
 public static function show_setting_msgs($plugslug = '')
 {
     //	if( ! isset($_GET['settings-updated']) || empty($_POST) ) return;
     if (empty($plugslug)) {
         $plugslug = Skeleteon_Generic::get_plug_var('plug_slug');
     }
     $setting_msgs = get_transient($plugslug . '_setting_msgs');
     if (!$setting_msgs) {
         return;
     }
     $ret = '<div class="dsms_alertwrap setting_msg_wrap">';
     $ret .= '<input id="dismiss_cbox_setting_msgs" type="checkbox" class="cbox_dismiss" role="button">';
     $ret .= '<label class="cbox_dismiss" for="dismiss_cbox_setting_msgs"><span class="btn btn-primary btn-xs">X ' . __('Dismiss') . '</span></label>';
     $ret .= '<div class="cbt_cont alert alert-success"> <i class="fa fa-check-square-o"></i> Settings saved succesfully. <br />';
     if ($setting_msgs) {
         $ret .= Skeleteon_Interface::gen_field('exp_setting_msgs', array('type' => 'togglebox_start', 'label' => 'Additional Details', 'std' => true), true);
         foreach ($setting_msgs as $k => $msgs) {
             $ret .= '<div class="alert alert-' . $k . ' pad"><ul>';
             foreach ($msgs as $msg) {
                 $ret .= '<li>' . $msg . '</li>';
             }
             $ret .= '</ul></div>';
         }
         $ret .= Skeleteon_Interface::gen_field(null, array('type' => 'togglebox_end'), true);
     }
     $ret .= '</div></div>';
     echo $ret;
     // Delete messages upon showing.
     delete_transient($plugslug . '_setting_msgs');
 }
コード例 #5
0
 function sanitize_typography($input, $k)
 {
     $output = wp_parse_args($input, array('face' => '', 'style' => '', 'size' => '', 'color' => '', 'subset' => ''));
     //				var_dump($input,$output,$k);
     //		die("111");
     // Check Google font variant for sanity. We should already have a google font transient in place. If we dont, just fall back to regular
     $rt = Skeleteon_Generic::get_plug_var('reg_transients');
     $gf_trans_name = $rt['google_fonts'];
     $google_font_faces = get_transient($gf_trans_name);
     if ($google_font_faces) {
         $is_google_font = array_key_exists($input['face'], $google_font_faces);
         if (!$is_google_font) {
             unset($output['subset']);
         }
         if ($is_google_font) {
             $fonts_styles = $google_font_faces[$input['face']]['variants'];
             $fonts_subsets = $google_font_faces[$input['face']]['subsets'];
             // Remove subset if the font doesnt have it.
             foreach ($input['subset'] as $isk => $isub) {
                 if (!in_array($isub, $fonts_subsets)) {
                     unset($output['subset'][$isk]);
                 }
             }
             if (!in_array($input['style'], $fonts_styles)) {
                 $output['style'] = 'regular';
             }
         }
         //		var_dump($fonts_styles);
         /*
         	if ( is_array( $input ) ) {		
         			foreach ( $input as $v ) {
         				$output[] = $v;
         			}
         		}*/
         //	if( ! in_array($input['style'],$fonts_styles) )	$output['style'] = 'regular';
     } else {
         $output['style'] = 'normal';
     }
     //	var_dump($input,$output,$k);
     //	die("111");
     /*
     		if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) {
     			if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) {
     				$output['face'] = '';
     			}
     		}
     		else {
     			$output['face']  = apply_filters( 'of_font_face', $output['face'] );
     		}*/
     //		$output['size']  = apply_filters( 'ske_font_size', $output['size'] );
     //		$output['style'] = apply_filters( 'ske_font_style', $output['style'] );
     return $output;
 }
コード例 #6
0
<?php

if (!isset($temp_vars)) {
    $temp_vars = Skeleteon_Generic::get_plug_vars();
}
?>
<div class="wrap">
		<?php 
Skeleteon_Admin::show_setting_msgs($temp_vars['plug_slug']);
?>
		<?php 
$tabs = array('main' => 'Main Settings', 'info' => 'Some Info');
// If a tab is requested set it as active, if not load the first tab.
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : key($tabs);
/*			foreach ( $tabs as $k => $tab_title ) {
				if( 
			}*/
/*	if( isset( $_GET[ 'tab' ] ) ) {
    $active_tab = $_GET[ 'tab' ];
} else if( $active_tab == 'social_options' ) {
    $active_tab = 'social_options';
} else if( $active_tab == 'input_examples' ) {
    $active_tab = 'input_examples';
} else {
    $active_tab = 'display_options';
} */
// screen menu_key
$curr_scr = get_current_screen()->id;
$curpage = substr($curr_scr, strpos($curr_scr, "_page_") + 6);
$menu_key = array_keys($temp_vars['screenhooks'], $curr_scr);
$smk = str_replace('_', '-', $menu_key[0]);
<?php

if (!isset($temp_vars)) {
    isset($this->vars) && is_array($this->vars) && !empty($this->vars) ? $temp_vars = $this->vars : ($temp_vars = Skeleteon_Generic::get_plug_vars());
}
?>

<?php 
//	var_dump(eopfw_get_plugin_data());
$pluginfo = Skeleteon_Generic::get_plug_data();
?>
<div class="well">
<ul>
<?php 
foreach ($pluginfo as $k => $pinf) {
    echo '<li><label>' . $k . '</label>: ' . $pinf . '</li>';
}
?>
</ul>
</div>
コード例 #8
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
//$setting_key = $this->vars['plug_slug'].'_demo_settings';
$settings_key = str_replace(array("render-metabox-", "-"), array("", "_"), basename(__FILE__, '.php'));
$plugslug = Skeleteon_Generic::get_plug_var('plug_slug');
$full_settings_key = $plugslug . '_' . $settings_key;
//var_dump($settings_key);
?>
<form method="post" action="options.php">
    <?php 
settings_fields($full_settings_key);
//
//	do_settings_sections( $settings_key );
//	get_settings($optk=null,$section=null,$sett_key=null,$def_pairs=false,$ign=true,$sanit=true) {
//$options = Skeleteon_Generic::get_settings('demo_settings');
$options = Skeleteon_Generic::get_settings_for($settings_key);
if ($options) {
    foreach ($options as $key => $field) {
        Skeleteon_Interface::gen_field($key, $field, $full_settings_key);
    }
}
submit_button(__('Save Changes'), 'primary', '', false);
submit_button(__('Restore'), 'secondary', 'reset_settings', false);
$storedvals = get_option($full_settings_key);
Skeleteon_Generic::vd($storedvals, true);
?>
</form>
コード例 #9
0
    function render_screen_debug_menu()
    {
        $k = array_keys(self::$menu_hooks, current_filter());
        $k = reset($k);
        ?>
        <div class="wrap" style="float:left; clear: both;">
        	<div id="debug-menu-screen" class="group col-md-6">
				<?php 
        $pluginfo = Skeleteon_Generic::get_plug_data();
        ?>
                <div class="well">
                <h3>Debug Information: </h3>
                <ul>
                <?php 
        foreach ($pluginfo as $ik => $pinf) {
            echo '<li><label>' . $ik . '</label>: ' . $pinf . '</li>';
        }
        ?>
                </ul>
                </div>
            </div>
           <div class="alert alert-info col-md-6">
                <h3>Hey!</h3>
                <p>This information is displayed automatically because the menu item <code><?php 
        echo $k;
        ?>
</code> had a corresponding <code><?php 
        echo 'render_screen_<b>' . $k . '()</b>';
        ?>
</code> function defined inside <pre><?php 
        echo plugin_basename(__FILE__);
        ?>
</pre></p>
                <p>Even if the menu callback function is not defined specifically under <code>$menu_items['<?php 
        echo $k;
        ?>
']['cb']</code>, if the corresponding <code><?php 
        echo 'render_screen_<b>' . $k . '()</b>';
        ?>
</code> function exists, it will be display here by the default <code><?php 
        echo 'render_screens';
        ?>
</code> function</p>
                <br />
                <?php 
        $this->explain_screens();
        ?>
           </div>            
		</div>
		<?php 
    }
コード例 #10
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
$plug_sett_optk = $this->vars['plug_opt'];
//var_dump(class_exists('Skeleteon_Generic'));
//var_dump($plug_sett_optk);
//Skeleteon_Generic::add_msg('missing_opt','opt missing','warning');
//Skeleteon_Generic::add_error('missing_opt','opt missing',array('type'=>'danger') );
//global $wp_settings_fields;
//var_dump($wp_settings_fields);
?>
<form method="post" action="options.php">
    <?php 
settings_fields($plug_sett_optk);
?>
    <?php 
do_settings_sections('plugin_settings');
/*$options = Skeleteon_Generic::get_settings_for('plugin_settings');
  if($options) {
      foreach ( $options as $key => $field ) {
          Skeleteon_Interface::gen_field( $key, $field );
      }
  }*/
submit_button(__('Save Changes'), 'primary', '', false);
submit_button(__('Restore'), 'secondary', 'reset_settings', false);
$storedvals = get_option($this->vars['plug_opt']);
Skeleteon_Generic::vd($storedvals);
?>
</form>
コード例 #11
0
 static function gen_uploader($settk, $_id, $_value, $_desc = '', $_name = '', $lang_slug = '')
 {
     $output = '';
     $id = '';
     $class = '';
     $int = '';
     $value = '';
     $name = '';
     $id = strip_tags(strtolower($_id));
     if (empty($lang_slug)) {
         $lang_slug = Skeleteon_Generic::get_plug_var('lang_slug');
     }
     // If a value is passed and we don't have a stored value, use the value that's passed through.
     if ($_value != '' && $value == '') {
         $value = $_value;
     }
     if ($_name != '') {
         $name = $_name;
     } else {
         $name = $settk . '[' . $id . ']';
     }
     if ($value) {
         $class = ' has-file';
     }
     //	var_dump($name);
     $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $name . '" value="' . $value . '" placeholder="' . __('No file chosen', $lang_slug) . '" />' . "\n";
     if (function_exists('wp_enqueue_media')) {
         if ($value == '') {
             $output .= '<input id="upload-' . $id . '" class="upload-button button" type="button" value="' . __('Upload', $lang_slug) . '" />' . "\n";
         } else {
             $output .= '<input id="remove-' . $id . '" class="remove-file button" type="button" value="' . __('Remove', $lang_slug) . '" />' . "\n";
         }
     } else {
         $output .= '<p><i>' . __('Upgrade your version of WordPress for full media support.', $lang_slug) . '</i></p>';
     }
     if ($_desc != '') {
         $output .= '<span class="of-metabox-desc">' . $_desc . '</span>' . "\n";
     }
     // add togglebox for preview
     // _eo-todo: remove hide preview if no pic
     $output .= '<input id="' . esc_attr($id) . '_prev_cboxt" type="checkbox" ';
     $output .= 'class="cbox_toggle_i upltogi" role="button"><label class="cbox_toggle uplprevtoglbl" for="' . esc_attr($id) . '_prev_cboxt">';
     $output .= '<span class="label label-success cbt_s">+ Show Preview</span><span class="label label-default cbt_h">— Hide Preview</span>';
     $output .= '</label>';
     $output .= '<div class="cbt_cont togglebox screenshot uplprev" id="' . $id . '-image">' . "\n";
     if ($value != '') {
         $remove = '<a class="uplrem remove-image btn btn-danger btn-xs">X Remove</a>';
         $image = preg_match('/(^.*\\.jpg|jpeg|png|gif|ico*)/i', $value);
         if ($image) {
             $output .= '<img src="' . $value . '" alt="" class="img-responsive" />' . $remove;
         } else {
             $parts = explode("/", $value);
             for ($i = 0; $i < sizeof($parts); ++$i) {
                 $title = $parts[$i];
             }
             // No output preview if it's not an image.
             $output .= '';
             // Standard generic output if it's not an image.
             $title = __('View File', $lang_slug);
             $output .= '<div class="no-image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">' . $title . '</a></span></div>';
         }
     }
     $output .= '</div>' . "\n";
     return $output;
 }
コード例 #12
0
 function set_vars()
 {
     $this->vars = Skeleteon_Generic::get_plug_vars();
 }
コード例 #13
0
 function sync_settings()
 {
     $plugslug = $this->vars['plug_slug'];
     $sync_msg = '';
     foreach ($this->all_settings as $sett_k => $settings) {
         $default_pairs = array();
         $set_optk = $plugslug . '_' . $sett_k;
         $stored_pairs = get_option($set_optk);
         foreach ($settings as $sect => $options) {
             //		var_dump($sect,$options);
             // If is section
             foreach ($options as $sk => $option) {
                 if (is_int($sk)) {
                     continue;
                 }
                 $std = array_key_exists('std', $option) ? $option['std'] : '';
                 //	var_dump($sk, $option);
                 $default_pairs[$sk] = $std;
             }
         }
         //				var_dump($default_pairs,$stored_pairs);
         //				var_dump($settings);
         if ($stored_pairs) {
             $new_pairs = array("newpants");
             $new_pairs = $stored_pairs;
             //	var_dump($stored_pairs);
             //	var_dump($default_pairs,$stored_pairs);
             //		var_dump($sett_k);
             //		var_dump($default_pairs,$stored_pairs);
             $new_opts = array_diff_key($default_pairs, $stored_pairs);
             $old_opts = array_diff_key($stored_pairs, $default_pairs);
             if (!empty($new_opts) || !empty($old_opts)) {
                 if ($new_opts) {
                     $sync_msg .= count($new_opts) . ' new options found for <code>' . $sett_k . '</code><br />';
                 }
                 if ($old_opts) {
                     $sync_msg .= count($old_opts) . ' old options found for <code>' . $sett_k . '</code><br />';
                 }
                 //	var_dump($new_opts,$old_opts);
                 if (!empty($new_opts)) {
                     foreach ($new_opts as $new_opt_k => $new_opt_v) {
                         $new_pairs[$new_opt_k] = $new_opt_v;
                     }
                 }
                 if (!empty($old_opts)) {
                     foreach ($old_opts as $old_opt_k => $old_opt_v) {
                         unset($new_pairs[$old_opt_k]);
                     }
                 }
                 var_dump($this->update_option($set_optk, $new_pairs));
                 //	var_dump(update_option($set_optk,$stored_pairs));
                 //	var_dump(update_option($set_optk,"456"));
                 var_dump($this->update_option("honey_thick_example_settings", $new_pairs));
                 var_dump($this->update_option("honey_thick_example_settings", "777"));
                 var_dump($this->update_option("123", $new_pairs));
                 //			add_filter( 'pre_update_option_'.$set_optk, 'myplugin_update_field_foo', 10, 2 );
                 //									var_dump($stored_pairs);
                 //					var_dump(function_exists('update_option'));
                 //wp_cache_delete ( 'alloptions', 'options' );
                 //var_dump($set_optk,$stored_pairs);
                 //	var_dump(update_option($set_optk,"22"));
                 //				var_dump(update_option("44","22"));
                 //			var_dump(update_option("honey_thick_demo_settings",$stored_pairs));
                 //		var_dump(update_option("honey_thick_demo_settingszz",$stored_pairs));
                 //	var_dump(update_option("777",$stored_pairs));
                 //				var_dump($wpdb->queries);
                 //		update_option("2323",$stored_pairs);
                 //			var_dump($stored_pairs);
                 //	add_action('shutdown',$this->update_option
             }
         }
         //		update_option($set_optk,$stored_pairs);
         //			$new_opts = array_diff_key($default_pairs,$stored_pairs);
         //	var_dump($sett_k,$settings,$stored_pairs,$default_pairs);
     }
     // foreach main
     if (!empty($sync_msg)) {
         return Skeleteon_Generic::add_trans_msg("settings_synced", sprintf(__('Settings Synced. <br />%s', $this->vars['lang_slug']), $sync_msg), 'info');
     } else {
         return false;
     }
 }
コード例 #14
0
 function sync_settings()
 {
     //	var_dump(self::$vars);
     //	var_dump(Skeleteon_Generic::get_plug_var('all_settings'));
     $all_settings = Skeleteon_Generic::get_plug_var('all_settings');
     $plugslug = self::$vars['plug_slug'];
     $sync_msg = '';
     foreach ($all_settings as $sett_k => $settings) {
         $default_pairs = array();
         $set_optk = $plugslug . '_' . $sett_k;
         $stored_pairs = get_option($set_optk);
         foreach ($settings as $sect => $options) {
             //		var_dump($sect,$options);
             // If is section
             foreach ($options as $sk => $option) {
                 if (is_int($sk)) {
                     continue;
                 }
                 $std = array_key_exists('std', $option) ? $option['std'] : '';
                 //	var_dump($sk, $option);
                 $default_pairs[$sk] = $std;
             }
         }
         //				var_dump($default_pairs,$stored_pairs);
         //				var_dump($settings);
         if ($stored_pairs) {
             var_dump($stored_pairs);
             //	var_dump($default_pairs,$stored_pairs);
             //		var_dump($sett_k);
             //		var_dump($default_pairs,$stored_pairs);
             $new_opts = array_diff_key($default_pairs, $stored_pairs);
             $old_opts = array_diff_key($stored_pairs, $default_pairs);
             if (!empty($new_opts) || !empty($old_opts)) {
                 if ($new_opts) {
                     $sync_msg .= count($new_opts) . ' new options found for <code>' . $sett_k . '</code><br />';
                 }
                 if ($old_opts) {
                     $sync_msg .= count($old_opts) . ' old options found for <code>' . $sett_k . '</code><br />';
                 }
                 //var_dump($new_opts,$old_opts);
                 if (!empty($new_opts)) {
                     foreach ($new_opts as $new_opt_k => $new_opt_v) {
                         $stored_pairs[$new_opt_k] = $new_opt_v;
                     }
                 }
                 if (!empty($old_opts)) {
                     foreach ($old_opts as $old_opt_k => $old_opt_v) {
                         unset($stored_pairs[$old_opt_k]);
                     }
                 }
                 //									var_dump($stored_pairs);
                 //					var_dump(function_exists('update_option'));
                 var_dump($set_optk, $stored_pairs);
                 update_option($set_optk, "22");
                 update_option("333", "22");
                 //		update_option("2323",$stored_pairs);
             }
         }
         //		update_option($set_optk,$stored_pairs);
         //			$new_opts = array_diff_key($default_pairs,$stored_pairs);
         //	var_dump($sett_k,$settings,$stored_pairs,$default_pairs);
     }
     // foreach main
     if (!empty($sync_msg)) {
         return Skeleteon_Generic::add_trans_msg("settings_synced", sprintf(__('Settings Synced. <br />%s', self::$vars['lang_slug']), $sync_msg), 'info');
     } else {
         return false;
     }
 }