/** * Content for 'Tools' tab * * @since 1.4 */ public function tools_page($saved_settings) { ?> <div class='menu_settings'> <h3 class='first'><?php _e("Tools", "megamenu"); ?> </h3> <table> <tr> <td class='mega-name'> <?php _e("Cache", "megamenu"); ?> <div class='mega-description'><?php _e("Use this tool to clear the CSS cache.", "megamenu"); ?> </div> </td> <td class='mega-value'> <form action="<?php echo admin_url('admin-post.php'); ?> " method="post"> <?php wp_nonce_field('megamenu_clear_css_cache'); ?> <input type="hidden" name="action" value="megamenu_clear_css_cache" /> <input type='submit' class='button button-secondary' value='<?php _e("Clear CSS Cache", "megamenu"); ?> ' /> </form> </td> </tr> <tr> <td class='mega-name'> <?php _e("Plugin Data", "megamenu"); ?> <div class='mega-description'><?php _e("Delete all saved Max Mega Menu plugin data from the database. Use with caution!", "megamenu"); ?> </div> </td> <td class='mega-value'> <form action="<?php echo admin_url('admin-post.php'); ?> " method="post"> <?php wp_nonce_field('megamenu_delete_data'); ?> <input type="hidden" name="action" value="megamenu_delete_data" /> <input type='submit' class='button button-secondary confirm' value='<?php _e("Delete Data", "megamenu"); ?> ' /> </form> </td> </tr> <tr> <td class='mega-name'> <?php _e("Export Theme", "megamenu"); ?> <div class='mega-description'><?php _e("Export a menu theme", "megamenu"); ?> </div> </td> <td class='mega-value'> <form method="post" action="<?php admin_url("admin.php?page=maxmegamenu&tab=tools"); ?> "> <?php if (isset($_POST['theme_export'])) { $style_manager = new Mega_Menu_Style_Manager(); $default_theme = $style_manager->get_default_theme(); $theme_to_export = $_POST['theme_export']; if (isset($this->themes[$theme_to_export])) { $theme_to_export = $this->themes[$theme_to_export]; $diff = array(); foreach ($default_theme as $key => $value) { if (isset($theme_to_export[$key]) && $theme_to_export[$key] != $value || $key == 'title') { $diff[$key] = $theme_to_export[$key]; } } if (isset($_POST['format']) && $_POST['format'] == 'json') { echo "<p>" . __("Log into the site you wish to import the theme to. Go to Mega Menu > Tools and paste this into the 'Import Theme' text area:") . "</p>"; echo "<textarea>" . htmlentities(json_encode($diff)) . "</textarea>"; } else { $key = strtolower(str_replace(" ", "_", $theme_to_export['title'])); $key .= "_" . time(); echo "<p>" . __("Paste this code into your themes functions.php file:") . "</p>"; echo '<textarea>'; echo 'function megamenu_add_theme_' . $key . '($themes) {'; echo "\n" . ' $themes["' . $key . '"] = array('; foreach ($diff as $theme_key => $value) { echo "\n '" . $theme_key . "' => '" . $value . "',"; } echo "\n" . ' );'; echo "\n" . ' return $themes;'; echo "\n" . '}'; echo "\n" . 'add_filter("megamenu_themes", "megamenu_add_theme_' . $key . '");'; echo '</textarea>'; } } } else { echo "<select name='theme_export'>"; foreach ($this->themes as $id => $theme) { echo "<option value='{$id}'>{$theme['title']}</option>"; } echo "</select>"; echo "<h4>" . __("Export Format", "megamenu") . "</h4>"; echo "<input value='json' type='radio' name='format'>" . __("JSON - I want to import this theme into another site I'm developing") . "<br />"; echo "<input value='php' type='radio' name='format'>" . __("PHP - I want to distribute this Menu Theme in a WordPress Theme I'm developing") . "<br />"; echo "<input type='submit' name='export' class='button button-secondary' value='" . __("Export Theme", "megamenu") . "' />"; } ?> </form> </td> </tr> <tr> <td class='mega-name'> <?php _e("Import Theme", "megamenu"); ?> <div class='mega-description'><?php _e("Import a menu theme", "megamenu"); ?> </div> </td> <td class='mega-value'> <form action="<?php echo admin_url('admin-post.php'); ?> " method="post"> <?php wp_nonce_field('megamenu_import_theme'); ?> <input type="hidden" name="action" value="megamenu_import_theme" /> <textarea name='data'></textarea> <input type='submit' class='button button-secondary' value='<?php _e("Import Theme", "megamenu"); ?> ' /> </form> </td> </tr> </table> </div> <?php }