D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
cwd
/
wp-content
/
themes
/
newsplus1
/
inc
/
Filename :
tools.php
back
Copy
<?php /* Copyrights (C) Arb4Host Network */ ?> <?php if ( !is_admin() ) { return; } class a4h_theme_tools { function __construct() { add_action('admin_menu', array(&$this, 'admin_menu')); } function enqueue_scripts() { wp_enqueue_style('admin-css', get_theme_file_uri('assets/css/admin-options.css', array(), THEME_VERSION)); wp_enqueue_style('fonts', get_theme_file_uri('assets/fonts/fonts.css', array(), THEME_VERSION)); } function admin_menu() { $page = add_management_page('أدوات '.THEME_NAME, 'أدوات '.THEME_NAME, 'manage_options', 'a4h_tools', array(&$this, 'options_page')); add_action("load-{$page}", array(&$this, 'import_export')); add_action("load-{$page}", array(&$this, 'enqueue_scripts')); } function import_export() { $site_url = get_option('siteurl'); $site_url = parse_url($site_url); $site_url = $site_url['host']; $type = isset($_GET['type']) ? $_GET['type'] : ''; if ( isset($_GET['action']) && $_GET['action'] == 'download_a4h_settings' ) { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="'.THEME_NAME_EN_VAR.'-'.$type.'-('.$site_url.')-'.date("d-M-y").'.dat"'); echo serialize($this->download_a4h_settings($type)); die(); } if ( isset($_POST['upload']) && check_admin_referer('a4h_options_nonce') ) { if ($_FILES["file"]["error"] > 0) { // error } else { $options = unserialize(file_get_contents($_FILES["file"]["tmp_name"])); if ( $options ) { foreach ( $options as $option ) { update_option($option->option_name, unserialize($option->option_value)); } } } wp_redirect(admin_url('admin.php?page=a4h_tools')); exit; } if ( isset($_POST['reset-settings']) && check_admin_referer('a4h_options_nonce') ) { if ( isset($_POST['reset_options']) ) { a4h_reset_settings('options'); } if ( isset($_POST['reset_ads']) ) { a4h_reset_settings('ads'); } if ( isset($_POST['reset_widgets']) ) { a4h_reset_settings('widgets'); } if ( isset($_POST['reset_admin_notices']) ) { a4h_reset_settings('admin_notices'); } } } function options_page() { ?> <div class="wrap"> <!-- content start --> <div class="mz-options"> <header class="mz-clearfix mz-options-header"> <a class="mz-a4h-link" target="_blank" href="<?php echo SUPPORT_LINK; ?>"><?php _e('Support', THEME_TEXT_DOMAIN); ?></a> <span class="mz-theme-name">أدوات <?php echo THEME_NAME; ?></span> </header> <main class="mz-options-inner"> <div class="mz-options-sections-outer"> <section id="mz-ads-content" class="mz-options-section"> <div class="mz-clearfix mz-options-item-outer"> <div class="mz-options-option-title">تصدير الإعدادات</div> <p> <a href="<?php echo admin_url('admin.php?page=a4h_tools&action=download_a4h_settings&type='.THEME_OPTIONS_VAR); ?>" class="button-secondary"><?php _e('Export Theme Settings', THEME_TEXT_DOMAIN); ?></a> </p> <p> <a href="<?php echo admin_url('admin.php?page=a4h_tools&action=download_a4h_settings&type='.THEME_ADS_VAR); ?>" class="button-secondary"><?php _e('Export Ads Settings', THEME_TEXT_DOMAIN); ?></a> </p> </div> <div class="mz-clearfix mz-options-item-outer"> <div class="mz-options-option-title">استيراد الإعدادات</div> <form action="" method="POST" enctype="multipart/form-data"> <p> <input type="file" name="file" /> <input type="submit" name="upload" id="upload" class="button-primary" value="<?php _e('Upload'); ?>" /> <?php wp_nonce_field('a4h_options_nonce'); ?> </p> </form> </div> <div class="mz-clearfix mz-options-item-outer"> <div class="mz-options-option-title">استعادة الإعدادات الافتراضية</div> <form method="post" action=""> <p> <input name="reset_options" type="checkbox" value="1" />القالب </p> <p> <input name="reset_ads" type="checkbox" value="1" />الإعلانات </p> <p> <input name="reset_widgets" type="checkbox" value="1" />الودجات </p> <p> <input name="reset_admin_notices" type="checkbox" value="1" />تنبيهات الأدمن </p> <p> <input name="reset-settings" class="button button-secondary" type="submit" value="استعادة الاعدادات الافتراضية" onclick="return confirm('هل أنت متأكد من الاستمرار؟')" > </p> <?php wp_nonce_field('a4h_options_nonce'); ?> </form> </div> </section> </div> </main> </div> <!-- content end --> </div> <?php } function download_a4h_settings($type) { global $wpdb; return $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name = '{$type}'"); } } new a4h_theme_tools;