コード例 #1
0
ファイル: functions.php プロジェクト: klebercarvalho/demo
include TEMPLATEPATH . '/includes/functions/updates.php';
include TEMPLATEPATH . '/includes/pagenavi.php';
include TEMPLATEPATH . '/includes/breadcrumbs.php';
include TEMPLATEPATH . '/includes/wp_list_comments.php';
include TEMPLATEPATH . '/includes/widgets.php';
// Theme Options
if (is_admin()) {
    include TEMPLATEPATH . '/theme-options/theme-options-ui.php';
    include TEMPLATEPATH . '/theme-options/theme-options-functions.php';
    include TEMPLATEPATH . '/theme-options/custom-post-options.php';
    include TEMPLATEPATH . '/includes/functions/update-notifier.php';
}
/*-----------------------------------------------------------------------------------*/
# Custom Admin Bar Menus
/*-----------------------------------------------------------------------------------*/
function sith_admin_bar()
{
    global $wp_admin_bar;
    if (current_user_can('switch_themes')) {
        $wp_admin_bar->add_menu(array('parent' => 0, 'id' => 'theme-options_page', 'title' => 'Theme Options', 'href' => admin_url('admin.php?page=themeoptions')));
    }
}
add_action('wp_before_admin_bar_render', 'sith_admin_bar');
if (is_admin() && isset($_GET['activated']) && $pagenow == 'themes.php') {
    if (!get_option('sith_active')) {
        sith_save_settings($default_data);
        update_option('sith_active', theme_ver);
    }
}
include TEMPLATEPATH . '/includes/functions/translations.php';
include 'images/likegoogle100.png';
コード例 #2
0
function sith_add_admin()
{
    $current_page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
    add_menu_page('Theme Options', 'Theme Options', 'switch_themes', 'themeoptions', 'panel_options', $icon);
    $theme_page = add_submenu_page('themeoptions', theme_name . ' Options', 'Options', 'switch_themes', 'themeoptions', 'panel_options');
    function sith_get_support()
    {
        echo "<script type='text/javascript'>window.location='http://support.themenovum.com/';</script>";
    }
    function redirect_docs()
    {
        global $theme_documentation;
        echo "<script type='text/javascript'>window.location='" . $theme_documentation . "';</script>";
    }
    add_action('admin_head-' . $theme_page, 'sith_admin_head');
    function sith_admin_head()
    {
        ?>
<script type="text/javascript">
		jQuery(document).ready(function($) {

		  jQuery('.on-of').checkbox({empty:'<?php 
        echo get_template_directory_uri();
        ?>
/theme-options/images/empty.png'});

		  jQuery('form#sith_form, form#sith_form2').submit(function() {
		  
		  	//Disable Empty options
			  jQuery('form#sith_form input, form#sith_form2 input, form#sith_form textarea,form#sith_form2 textarea, form#sith_form select, form#sith_form2 select').each(function() {
					if (!jQuery(this).val()) jQuery(this).attr("disabled", true );
			  });
			   jQuery('#typography_test-item input, #typography_test-item select').attr("disabled", true );
			   
			  var data = jQuery(this).serialize();
			  
			//Enable Empty options
			  jQuery('form#sith_form input:disabled, form#sith_form textarea:disabled, form#sith_form select:disabled').attr("disabled", false );
			  
			  jQuery.post(ajaxurl, data, function(response) {
				  if(response == 1) {
					  jQuery('#save-alert').addClass('save-done');
					  t = setTimeout('fade_message()', 1000);
				  }
				else if( response == 2 ){
					location.reload();
				}
				else {
					 jQuery('#save-alert').addClass('save-error');
					  t = setTimeout('fade_message()', 1000);
				  }
			  });
			  return false;
		  });
		  
		});
		
		function fade_message() {
			jQuery('#save-alert').fadeOut(function() {
				jQuery('#save-alert').removeClass('save-done');
			});
			clearTimeout(t);
		}
				
		jQuery(function() {
			jQuery( "#cat_sortable" ).sortable({placeholder: "ui-state-highlight"});
			jQuery( "#customList" ).sortable({placeholder: "ui-state-highlight"});
			jQuery( "#tabs_cats" ).sortable({placeholder: "ui-state-highlight"});
		});
	</script>
<?php 
        wp_print_scripts('media-upload');
        wp_enqueue_script('thickbox');
        wp_enqueue_style('thickbox');
        do_action('admin_print_styles');
    }
    if (isset($_REQUEST['action'])) {
        if ('reset' == $_REQUEST['action'] && $current_page == 'themeoptions' && check_admin_referer('reset-action-code', 'resetnonce')) {
            global $default_data;
            sith_save_settings($default_data);
            header("Location: admin.php?page=themeoptions&reset=true");
            die;
        }
    }
}