Ejemplo n.º 1
0
 function woothemes_add_admin()
 {
     global $query_string;
     global $current_user;
     $current_user_id = $current_user->user_login;
     $super_user = get_option('framework_woo_super_user');
     $themename = get_option('woo_themename');
     $shortname = get_option('woo_shortname');
     // Reset the settings, sanitizing the various requests made.
     // Use a SWITCH to determine which settings to update.
     /* Make sure we're making a request.
       	------------------------------------------------------------*/
     if (isset($_REQUEST['page'])) {
         // Sanitize page being requested.
         $_page = '';
         $_page = mysql_real_escape_string(strtolower(trim(strip_tags($_REQUEST['page']))));
         // Sanitize action being requested.
         $_action = '';
         if (isset($_REQUEST['woo_save'])) {
             $_action = mysql_real_escape_string(strtolower(trim(strip_tags($_REQUEST['woo_save']))));
         }
         // End IF Statement
         // If the action is "reset", run the SWITCH.
         /* Perform settings reset.
          		------------------------------------------------------------*/
         if ($_action == 'reset') {
             // Add nonce security check.
             if (function_exists('check_ajax_referer')) {
                 if ($_page == 'woothemes_seo') {
                     check_ajax_referer('wooframework-seo-options-reset', '_ajax_nonce');
                 } else {
                     check_ajax_referer('wooframework-theme-options-reset', '_ajax_nonce');
                 }
             }
             // End IF Statement
             switch ($_page) {
                 case 'woothemes':
                     $options = get_option('woo_template');
                     woo_reset_options($options, 'woothemes');
                     header("Location: admin.php?page=woothemes&reset=true");
                     die;
                     break;
                 case 'woothemes_framework_settings':
                     $options = get_option('woo_framework_template');
                     woo_reset_options($options);
                     header("Location: admin.php?page=woothemes_framework_settings&reset=true");
                     die;
                     break;
                 case 'woothemes_seo':
                     $options = get_option('woo_seo_template');
                     woo_reset_options($options);
                     header("Location: admin.php?page=woothemes_seo&reset=true");
                     die;
                     break;
                 case 'woothemes_sbm':
                     delete_option('sbm_woo_sbm_options');
                     header("Location: admin.php?page=woothemes_sbm&reset=true");
                     die;
                     break;
             }
             // End SWITCH Statement
         }
         // End IF Statement
     }
     // End IF Statement
     // Check all the Options, then if the no options are created for a relative sub-page... it's not created.
     if (get_option('framework_woo_backend_icon')) {
         $icon = get_option('framework_woo_backend_icon');
     } else {
         $icon = get_template_directory_uri() . '/functions/images/woo-icon.png';
     }
     if (function_exists('add_object_page')) {
         add_object_page('Page Title', $themename, 'manage_options', 'woothemes', 'woothemes_options_page', $icon);
     } else {
         add_menu_page('Page Title', $themename, 'manage_options', 'woothemes_home', 'woothemes_options_page', $icon);
     }
     $woopage = add_submenu_page('woothemes', $themename, __('Theme Options', 'woothemes'), 'manage_options', 'woothemes', 'woothemes_options_page');
     // Default
     // Framework Settings Menu Item
     $wooframeworksettings = '';
     if ($super_user == $current_user_id || empty($super_user)) {
         $wooframeworksettings = add_submenu_page('woothemes', __('Framework Settings', 'woothemes'), __('Framework Settings', 'woothemes'), 'manage_options', 'woothemes_framework_settings', 'woothemes_framework_settings_page');
     }
     // Add SEO Menu Item
     $wooseo = '';
     if (get_option('framework_woo_seo_disable') != 'true') {
         $wooseo = add_submenu_page('woothemes', 'SEO', 'SEO', 'manage_options', 'woothemes_seo', 'woothemes_seo_page');
     }
     // Add Sidebar Manager Menu Item
     $woosbm = '';
     if (get_option('framework_woo_sbm_disable') != 'true') {
         $woosbm = add_submenu_page('woothemes', 'Sidebar Manager', 'Sidebar Manager', 'manage_options', 'woothemes_sbm', 'woothemes_sbm_page');
     }
     // Woothemes Content Builder
     if (function_exists('woothemes_content_builder_menu')) {
         woothemes_content_builder_menu();
     }
     // Custom Navigation Menu Item
     if (function_exists('woo_custom_navigation_menu')) {
         woo_custom_navigation_menu();
     }
     // Update Framework Menu Item
     if ($super_user == $current_user_id || empty($super_user)) {
         $woothemepage = add_submenu_page('woothemes', 'WooFramework Update', 'Update Framework', 'manage_options', 'woothemes_framework_update', 'woothemes_framework_update_page');
     }
     // Update Timthumb Menu Item
     $file_located = locate_template('thumb.php');
     if ($file_located != '') {
         $file_test = woo_check_if_thumbs_are_equal($file_located, true);
     } else {
         $file_test = false;
     }
     $timthumb_update = get_option('woo_timthumb_update');
     if (($super_user == $current_user_id || empty($super_user)) && $timthumb_update == '' && $file_test) {
         $woothemepage = add_submenu_page('woothemes', 'Timthumb Update', 'Update Timthumb', 'manage_options', 'woothemes_timthumb_update', 'woothemes_timthumb_update_page');
     }
     // Buy Themes Menu Item
     if (get_option('framework_woo_buy_themes_disable') != 'true') {
         $woothemepage = add_submenu_page('woothemes', __('Available WooThemes', 'woothemes'), __('Buy Themes', 'woothemes'), 'manage_options', 'woothemes_themes', 'woothemes_more_themes_page');
         add_action("admin_print_scripts-{$woothemepage}", 'woo_load_only');
         add_action("admin_print_styles-{$woothemepage}", 'woo_framework_load_css');
     }
     // Add framework functionaily to the head individually
     add_action("admin_print_scripts-{$woopage}", 'woo_load_only');
     add_action("admin_print_scripts-{$wooframeworksettings}", 'woo_load_only');
     add_action("admin_print_scripts-{$wooseo}", 'woo_load_only');
     add_action("admin_print_scripts-{$woosbm}", 'woo_load_only');
     // Load Framework CSS Files
     add_action("admin_print_styles-{$woopage}", 'woo_framework_load_css');
     add_action("admin_print_styles-{$wooframeworksettings}", 'woo_framework_load_css');
     add_action("admin_print_styles-{$wooseo}", 'woo_framework_load_css');
     add_action("admin_print_styles-{$woosbm}", 'woo_framework_load_css');
     // Add the non-JavaScript "save" to the load of each of the screens.
     add_action("load-{$woopage}", 'woo_nonajax_callback');
     add_action("load-{$wooframeworksettings}", 'woo_nonajax_callback');
     add_action("load-{$wooseo}", 'woo_nonajax_callback');
     // add_action( "load-$woosbm", 'woo_nonajax_callback' );
 }
Ejemplo n.º 2
0
function woothemes_timthumb_update_page()
{
    // Setup data
    $timthumb_update = get_option('woo_timthumb_update');
    $url = admin_url('admin.php?page=woothemes_framework_update');
    // Do the update
    if (isset($_POST['woo_update_save'])) {
        // Read in the old file
        $filename = locate_template('thumb.php');
        // If File exists
        if ($filename != '') {
            // Call function test
            $file_read = woo_check_if_thumbs_are_equal($filename);
            $file_open = true;
            $file_write = false;
            // File was readable
            if ($file_read) {
                // Open file
                $file = fopen($filename, "w") or $file_open = false;
                // File opened successfully
                if ($file_open) {
                    // New File Contents
                    $new_file_contents = woo_thumb_new_contents();
                    $fwrite = fwrite($file, $new_file_contents);
                    if ($fwrite === false) {
                        // Write Fail
                        $file_write = false;
                    } else {
                        // Write Success
                        $file_write = true;
                    }
                    // End If Statement
                    fclose($file);
                }
                // End If Statement
                if ($file_open && $file_write) {
                    update_option('woo_timthumb_update', 'true');
                }
                // End If Statement
            } else {
                echo 'An error occurred while reading your current thumb.php';
            }
            // End If Statement
        } else {
            echo 'File does not exist.';
        }
        // End If Statement
    }
    // Get the setting for update
    $timthumb_update = get_option('woo_timthumb_update');
    ?>
            <div class="wrap themes-page">

            <?php 
    $localversion = get_option('woo_framework_version');
    $remoteversion = woo_get_fw_version();
    // Test if new version
    $upd = false;
    $loc = explode('.', $localversion);
    $rem = explode('.', $remoteversion);
    if ($loc[0] < $rem[0]) {
        $upd = true;
    } elseif ($loc[1] < $rem[1]) {
        $upd = true;
    } elseif ($loc[2] < $rem[2]) {
        $upd = true;
    }
    ?>
            <div class="icon32" id="icon-tools"><br></div>
            <h2>TimThumb Update</h2>
            <span style="display:none"><?php 
    echo $method;
    ?>
</span>
            <form method="post"  enctype="multipart/form-data" id="wooform" action="<?php 
    /* echo $url; */
    ?>
">

                <?php 
    if ($upd || $timthumb_update == '') {
        ?>
                <?php 
        wp_nonce_field('update-options');
        ?>
                <h3>A new version of TimThumb is available.</h3>
                <p>This updater will remove the old version of TimThumb (thumb.php) in your theme folder, and use the new TimThumb in the WooFramework.</p>

                <input type="submit" class="button" value="Update Timthumb" />
                <?php 
    } elseif ($file_open && $file_write) {
        ?>
 
                <h3>Thank you for updating your TimThumb. This section will now disable itself.</h3>
                <?php 
    } else {
        ?>
                <h3>Your TimThumb has been updated already.</h3>
                <?php 
    }
    ?>
                <input type="hidden" name="woo_update_save" value="save" />
                
            </form>
            </div>
            <?php 
}