/** * Display upload form * * Check if the server allow unzipping archives * * @return string */ public function update_zip_form() { if (class_exists('ZipArchive')) { if (wolf_check_folder(WOLF_THEME_DIR . '/tmp')) { $this->form(); } } else { echo '<br>'; printf(__('<em>You server configuration does not allow you to update by uploading a zip. You need %s installed on your server. You will have to update the theme via FTP.</em>', 'wolf'), 'ZipArchive'); } }
/** * Display upload form * * Check if the server allow unzipping archives * * @return string */ public function do_update_zip() { if (class_exists('ZipArchive')) { $this->theme_dir = WOLF_THEME_DIR; $this->tmp_dir = WOLF_THEME_DIR . '/tmp'; if (wolf_check_folder($this->tmp_dir)) { $this->do_import(); } } else { echo '<br>'; printf(__('<em>You server configuration does not allow you to import content by uploading a zip. You need %s installed on your server.</em>', 'wolf'), 'ZipArchive'); echo $this->fallback_error_message(); } }
/** * Display error message if ZipArchive not available * * Check if the server allow unzipping archives * * @param bool $echo * @return bool|string */ public function can_use_zip($echo = false) { if (class_exists('ZipArchive')) { $this->theme_dir = WOLF_THEME_DIR; $this->tmp_dir = WOLF_THEME_DIR . '/tmp'; if (wolf_check_folder($this->tmp_dir)) { return true; } } else { if ($echo) { echo '<br>'; printf(__('<em>You server configuration does not allow you to import content by uploading a zip. You need <strong>%s</strong> installed on your server.</em>', 'wolf'), 'ZipArchive'); echo $this->fallback_error_message(); } return false; } }
/** * Render Theme Options inputs */ public function render() { $theme_version = 'v.' . WOLF_THEME_VERSION; /* If a child theme is used and update notces are enabled, we show the parent theme version */ if (is_child_theme() && WOLF_UPDATE_NOTICE) { $theme_version = sprintf(__('v.%1$s (Parent Theme v.%2$s)', 'wolf'), wp_get_theme()->Version, WOLF_THEME_VERSION); } ?> <div id="wolf-framework-messages"> <?php // Check for theme update and set an admin notification if needed wolf_theme_update_notification_message(); if (WOLF_ENABLE_OPTIONS_EXPORTER) { wolf_check_folder(WOLF_THEME_DIR . '/includes/admin/export'); } ?> </div> <div class="wrap"> <form id="wolf-theme-options-form" method="post" action="<?php echo esc_url(admin_url('admin.php?page=wolf-theme-options')); ?> " enctype="multipart/form-data"> <?php wp_nonce_field('wolf_save_theme_options', 'wolf_save_theme_options_nonce'); ?> <h2 class="nav-tab-wrapper"> <div class="tabs" id="tabs1"> <?php foreach ($this->options as $value) { ?> <?php if ($value['type'] == 'open') { ?> <a href="#<?php echo sanitize_title($value['label']); ?> " class="nav-tab"><?php echo sanitize_text_field($value['label']); ?> </a> <?php } } ?> <?php if (class_exists('ZipArchive') && WOLF_ENABLE_OPTIONS_EXPORTER) { ?> <a href="#import" class="nav-tab"><?php _e('Export/Import', 'wolf'); ?> </a> <?php } ?> </div> </h2> <div class="content"> <?php foreach ($this->options as $value) { if (!isset($value['def'])) { $value['def'] = ''; } if (!isset($value['desc'])) { $value['desc'] = ''; } if ($value['type'] == 'open') { ?> <div id="<?php echo sanitize_title($value['label']); ?> " class="wolf-options-panel"> <p><?php echo sanitize_text_field($value['desc']); ?> </p> <?php } elseif ($value['type'] == 'close') { // vertical-align:middle; margin-left:10px; display:none; ?> <div class="wolf-options-actions"> <span class="submit"> <input name="wolf-theme-options-save" type="submit" class="wolf-theme-options-save button-primary menu-save" value="<?php _e('Save changes', 'wolf'); ?> "> <img class="options-loader" style="vertical-align:middle; margin-left:10px; display:none;" src="<?php echo esc_url(admin_url('images/loading.gif')); ?> " alt="loader"> <div style="float:none; clear:both"></div> </span> <div class="clear"></div> </div> </div><!-- panel --> <?php } elseif ($value['type'] == 'subtitle') { ?> <div class="wolf_title wolf_subtitle"> <h3> <?php echo sanitize_text_field($value['label']); ?> <br><small><?php echo sanitize_text_field($value['desc']); ?> </small> </h3> <div class="clear"></div> </div> <?php } elseif ($value['type'] == 'section_open') { $title = isset($value['label']) ? $value['label'] : ''; $desc = isset($value['desc']) ? $value['desc'] : ''; $section_id = isset($value['id']) ? $value['id'] : 'section'; $dependency = isset($value['dependency']) ? $value['dependency'] : array(); $class = "option-section-{$section_id}"; $data = ''; if (array() != $dependency) { $class .= ' has-dependency'; $data .= ' data-dependency-element="' . $dependency['element'] . '"'; $value_list = ''; foreach ($dependency['value'] as $value) { $value_list .= '"' . $value . '",'; } $value_list = rtrim($value_list, ','); $dependency_value = "[{$value_list}]"; $data .= " data-dependency-values='{$dependency_value}'"; } ?> <div class="<?php echo esc_attr($class); ?> "<?php echo $data; ?> > <div class="section-title"> <?php if ($title) { ?> <h3><?php echo sanitize_text_field($title); ?> </h3> <?php } ?> <p class="description"><?php echo $desc; ?> </p> </div> <table class="form-table"> <tbody> <?php } elseif ($value['type'] == 'section_close') { ?> </tbody> </table> </div> <?php } else { $this->do_input($value); } // foreach $options } ?> <?php if (class_exists('ZipArchive') && WOLF_ENABLE_OPTIONS_EXPORTER) { ?> <div id="import" class="wolf-options-panel"> <p><?php _e('Here you can export or import your theme options in zip file format', 'wolf'); ?> </p> <p> <input type="file" name="wolf-options-import-file"> <input id="wolf-import-options" type="submit" name="wolf-options-import-file-submit" class="button" value="<?php _e('Import Options', 'wolf'); ?> "> </p> <p> <input id="wolf-export-options" type="submit" name="wolf-options-export-file-submit" class="button" value="<?php _e('Export Options', 'wolf'); ?> "> </p> </div> <?php } ?> <input type="hidden" name="action" value="save"> </form> </div> <!-- .content --> <?php $reset_options_confirm = __('Are you sure to want to reset all options ?', 'wolf'); ?> <div id="wolf-options-footer"> <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wolf-theme-options')); ?> "> <p id="reset"> <input name="wolf-reset-all-options" type="submit" value="<?php _e('Reset all options', 'wolf'); ?> " onclick="if (window.confirm( '<?php echo esc_js($reset_options_confirm); ?> ' ) ) {location.href='default.htm';return true;} else {return false;}"> <input type="hidden" name="action" value="wolf-reset-all-options"> </p> </form> <p id="theme-version"><?php echo sanitize_text_field(wp_get_theme()->Name); ?> <small><?php echo sanitize_text_field($theme_version); ?> </small></p> </div> </div><!-- .wrap --> <?php if (WOLF_DEBUG) { echo "<br><br>options"; debug(get_option('wolf_theme_options_' . wolf_get_theme_slug())); echo "<br><br>posted"; debug($_POST); } //end wolf_options_admin }