Esempio n. 1
0
function ct_on_admin_init()
{
    // if there is a submit to update theme
    if (isset($_POST['ct_update_theme'])) {
        $envato_username = ot_get_option('envato_username', '');
        $envato_api = ot_get_option('envato_api', '');
        // if user has entered username and api
        if ($envato_username != '' && $envato_api != '') {
            // include the library
            require_once locate_template('/inc/plugins/envato-wordpress-toolkit/class-envato-wordpress-theme-upgrader.php');
            $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api);
            $upgrader->upgrade_theme(PARENT_THEME);
            add_action('admin_notices', 'ct_admin_notice_theme_updated');
        }
        //add_action( 'admin_notices', 'ct_admin_notice_theme_updated' );
    } else {
        // if Auto Update is set
        if (ot_get_option('envato_auto_update') == 'on') {
            $envato_username = ot_get_option('envato_username', '');
            $envato_api = ot_get_option('envato_api', '');
            // if user has entered username and api
            if ($envato_username != '' && $envato_api != '') {
                // include the library
                require_once locate_template('/inc/plugins/envato-wordpress-toolkit/class-envato-wordpress-theme-upgrader.php');
                $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api);
                if (ct_check_for_update(PARENT_THEME) == 1) {
                    $upgrader->upgrade_theme(PARENT_THEME);
                    add_action('admin_notices', 'ct_admin_notice_theme_updated');
                }
            }
        }
    }
}
 /**
  * Loads the content for each page
  *
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function display_page()
 {
     $screen = get_current_screen();
     /* loop through settings */
     foreach ((array) $this->options as $option) {
         /* loop through pages */
         foreach ((array) $this->get_pages($option) as $page) {
             /* verify page */
             if (!isset($page['hidden_page']) && $screen->id == $this->page_hook[$page['id']]) {
                 $show_buttons = isset($page['show_buttons']) && $page['show_buttons'] == false ? false : true;
                 /* update active layout content */
                 if (isset($_REQUEST['settings-updated']) && $_REQUEST['settings-updated'] == 'true') {
                     $layouts = get_option(ot_layouts_id());
                     /* has active layout */
                     if (isset($layouts['active_layout'])) {
                         $option_tree = get_option($option['id']);
                         $layouts[$layouts['active_layout']] = ot_encode(serialize($option_tree));
                         update_option(ot_layouts_id(), $layouts);
                     }
                 }
                 echo '<div class="wrap settings-wrap" id ="page-' . $page['id'] . '">';
                 echo '<h2>' . $page['page_title'] . '</h2>';
                 echo ot_alert_message($page);
                 settings_errors('option-tree');
                 /* Header */
                 echo '<div id="option-tree-header-wrap">';
                 echo '<ul id="option-tree-header">';
                 echo '<li id="option-tree-logo">' . apply_filters('ot_header_logo_link', '<a href="http://wordpress.org/extend/plugins/option-tree/" target="_blank">OptionTree</a>', $page['id']) . '</li>';
                 echo '<li id="option-tree-version"><span>' . apply_filters('ot_header_version_text', 'OptionTree ' . OT_VERSION, $page['id']) . '</span></li>';
                 // Add additional theme specific links here.
                 do_action('ot_header_list', $page['id']);
                 echo '</ul>';
                 /* layouts form */
                 if ($page['id'] == 'ot_theme_options' && OT_SHOW_NEW_LAYOUT == true) {
                     ot_theme_options_layouts_form();
                 }
                 echo '</div>';
                 /* remove forms on the custom settings pages */
                 if ($show_buttons) {
                     echo '<form action="options.php" method="post" id="option-tree-settings-api">';
                     settings_fields($option['id']);
                 } else {
                     echo '<div id="option-tree-settings-api">';
                 }
                 /* Sub Header */
                 echo '<div id="option-tree-sub-header">';
                 echo '<span class="option-tree-ui-button left image"></span>';
                 $current_theme = wp_get_theme(PARENT_THEME);
                 echo '<span class="option-tree-ui-button left vesion ">ver. ' . $current_theme->get('Version') . '</span>';
                 if ($show_buttons) {
                     echo '<button class="option-tree-ui-button grey right">' . $page['button_text'] . '</button>';
                     echo '<button class="option-tree-ui-button grey right imgok"></button>';
                 }
                 echo '<span class="option-tree-ui-button right document"><a href="http://doc.cactusthemes.com/truemag/">Documentation</a></span>';
                 echo '<span class="option-tree-ui-button grey right imgok1"><a href="#"></a></span>';
                 echo '<span class="option-tree-ui-button grey right support"><a href="http://ticket.cactusthemes.com/">Support Forum</a></span>';
                 echo '<span class="option-tree-ui-button grey right imgok2"><a href="#"></a></span>';
                 if (ct_check_for_update(PARENT_THEME) == 1) {
                     echo '<button class="button right" style="margin:6px" name="ct_update_theme" type="submit" value="ct_update_theme" onclick="jQuery(\'#option-tree-settings-api\').attr(\'action\',\'themes.php?page=ot-theme-options&ct_update_theme=true\')">' . __('New Version Found! Update Theme?', 'cactusthemes') . '</button>';
                 }
                 echo '</div>';
                 /* Navigation */
                 echo '<div class="ui-tabs">';
                 /* check for sections */
                 if (isset($page['sections']) && count($page['sections']) > 0) {
                     echo '<ul class="ui-tabs-nav">';
                     /* loop through page sections */
                     foreach ((array) $page['sections'] as $section) {
                         echo '<li id="tab_' . $section['id'] . '"><a href="#section_' . $section['id'] . '">' . $section['title'] . '</a></li>';
                     }
                     echo '</ul>';
                 }
                 /* sections */
                 echo '<div id="poststuff" class="metabox-holder">';
                 echo '<div id="post-body">';
                 echo '<div id="post-body-content">';
                 $this->do_settings_sections($_GET['page']);
                 echo '</div>';
                 echo '</div>';
                 echo '</div>';
                 echo '<div class="clear"></div>';
                 echo '</div>';
                 /* buttons */
                 if ($show_buttons) {
                     echo '<div class="option-tree-ui-buttons">';
                     echo '<button class="option-tree-ui-button blue right">' . $page['button_text'] . '</button>';
                     echo '</div>';
                 }
                 echo $show_buttons ? '</form>' : '</div>';
                 /* reset button */
                 if ($show_buttons) {
                     echo '<form method="post" action="' . str_replace('&settings-updated=true', '', $_SERVER["REQUEST_URI"]) . '">';
                     /* form nonce */
                     wp_nonce_field('option_tree_reset_form', 'option_tree_reset_nonce');
                     echo '<input type="hidden" name="action" value="reset" />';
                     echo '<button type="submit" class="option-tree-ui-button red left reset-settings" title="' . __('Reset Options', 'option-tree') . '">' . __('Reset Options', 'option-tree') . '</button>';
                     /* Display Import Sample Data Button */
                     echo '<a href="' . str_replace('&settings-updated=true', '', $_SERVER["REQUEST_URI"]) . '&import_data=true" class="button red" style="left:30px;position: relative;top: -40px;height: 30px; padding-top: 1px" onclick="return confirm(\'This will import sample data. It may take a couple of minitues to finish. Are you sure?\');">' . __('Import Sample Data', '') . '</a>';
                     echo '</form>';
                 }
                 echo '</div>';
             }
         }
     }
     return false;
 }
Esempio n. 3
0
function ct_on_admin_init()
{
    // if there is a submit to update theme
    if (isset($_POST['ct_update_theme'])) {
        ct_do_update_theme();
        //add_action( 'admin_notices', 'ct_admin_notice_theme_updated' );
    } else {
        // if Auto Update is set
        if (ot_get_option('envato_auto_update', 0) == 1) {
            if (ct_check_for_update(PARENT_THEME) == 1) {
                ct_do_update_theme();
            }
        }
    }
}