コード例 #1
0
ファイル: class-imexport.php プロジェクト: nil-vn/beautysite
 /**
  * Import XML and update settings
  * 
  * @access  public
  * @since   2.0.0
  * @param   string $filename
  * @uses    current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
  * @return  void
  */
 public function import_file($filename = FALSE)
 {
     if (!current_user_can('manage_options')) {
         wp_die(__('Options not update - you don‘t have the privilidges to do this!', parent::get_textdomain()));
     }
     // use tmp file
     if (!$filename) {
         $filename = $_FILES['xml']['tmp_name'];
     }
     $filename = preg_replace("/\\<\\!\\[CDATA\\[(.*?)\\]\\]\\>/ies", "'[CDATA]' . base64_encode('\$1') . '[/CDATA]'", $filename);
     $filename = utf8_encode($filename);
     $matches = simplexml_load_file($filename);
     // create array from xml
     $button = array();
     foreach ($matches->quicktag as $key) {
         foreach ($key as $value) {
             $buttons[$value->getName()] = $value;
         }
         $button[] = $buttons;
     }
     $options['buttons'] = $button;
     // validate the values from xml
     $options = parent::validate_settings($options);
     // update settings in database
     if (is_multisite() && is_plugin_active_for_network(parent::get_plugin_string())) {
         update_site_option(parent::get_option_string(), $options);
     } else {
         update_option(parent::get_option_string(), $options);
     }
 }
コード例 #2
0
 /**
  * Import json and update settings
  *
  * @access   public
  * @since    2.0.0
  *
  * @internal param bool|string $filename
  *
  * @uses     current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
  * @return  void
  */
 public function import_file()
 {
     if (!current_user_can('manage_options')) {
         wp_die(esc_html__('Options not update - you don&lsquo;t have the privileges to do this!', parent::get_textdomain()));
     }
     check_admin_referer(parent::$nonce_string);
     $extension = explode('.', $_FILES['import_file']['name']);
     $extension = end($extension);
     if ($extension !== 'json') {
         wp_die(esc_html__('Please upload a valid .json file', parent::get_textdomain()));
     }
     $import_file = $_FILES['import_file']['tmp_name'];
     if (empty($import_file)) {
         wp_die(esc_html__('Please upload a file to import.', parent::get_textdomain()));
     }
     // Retrieve the settings from the file and convert the json object to an array.
     $options = (array) json_decode(file_get_contents($import_file), TRUE);
     if (is_multisite() && is_plugin_active_for_network(self::$plugin)) {
         update_site_option(self::$option_string, $options);
     } else {
         update_option(self::$option_string, $options);
     }
     // redirect to settings page in network
     if (is_multisite() && is_plugin_active_for_network(self::$plugin)) {
         wp_redirect(add_query_arg(array('page' => self::$plugin, 'updated' => 'true'), network_admin_url('settings.php')));
     } else {
         $page = str_replace(basename(__FILE__), 'class-settings.php', plugin_basename(__FILE__));
         wp_redirect(add_query_arg(array('page' => $page, 'updated' => 'true'), admin_url('options-general.php')));
     }
     exit;
 }
コード例 #3
0
 /**
  * Constructor, init on defined hooks of WP and include second class
  *
  * @access  public
  * @since   0.0.2
  * @uses    register_activation_hook, register_uninstall_hook, add_action
  * @return \Add_Quicktag_Code_Quicktags
  */
 private function __construct()
 {
     self::$textdomain = parent::get_textdomain();
     add_action('addquicktag_settings_form_page', array($this, 'get_code_quicktag_area'));
 }
コード例 #4
0
    /**
     * Add settings area
     *
     * @param $options
     */
    public function get_remove_quicktag_area($options)
    {
        if (!isset($options['core_buttons'])) {
            $options['core_buttons'] = array();
        }
        ?>
		<h3><?php 
        esc_html_e('Remove Core Quicktag buttons', parent::get_textdomain());
        ?>
</h3>
		<p><?php 
        esc_html_e('Select the checkbox below to remove a core quicktags in the editors of the respective post type.', $this->get_textdomain());
        ?>
</p>

		<?php 
        // loop about the post types, create html an values for title in table
        $pt_title = '';
        $pt_colgroup = '';
        foreach ($this->get_post_types_for_js() as $post_type) {
            $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
            $pt_colgroup .= '<colgroup></colgroup>' . "\n";
        }
        ?>

		<table class="widefat form-table rmnlCoreQuicktagSettings">
			<colgroup></colgroup>
			<?php 
        echo $pt_colgroup;
        ?>
			<colgroup></colgroup>

			<tr>
				<th class="row-title"><?php 
        esc_html_e('Button', parent::get_textdomain());
        ?>
</th>
				<?php 
        echo $pt_title;
        ?>
				<th class="row-title num" style="width:3%;">&#x2714;</th>
			</tr>

			<?php 
        // Convert string to array
        $core_buttons = explode(',', self::$core_quicktags);
        // Loop over items to remove and unset them from the buttons
        $i = 999;
        foreach ($core_buttons as $key => $value) {
            // same style as in editor
            if ('strong' === $value) {
                $text = 'b';
                $style = ' style="font-weight: bold;"';
            } else {
                if ('em' === $value) {
                    $text = 'i';
                    $style = ' style="font-style: italic;"';
                } else {
                    if ('link' === $value) {
                        $text = $value;
                        $style = ' style="text-decoration: underline;"';
                    } else {
                        if ('del' === $value) {
                            $text = $value;
                            $style = ' style="text-decoration: line-through;"';
                        } else {
                            if ('block' === $value) {
                                $text = 'b-quote';
                                $style = '';
                            } else {
                                $text = $value;
                                $style = '';
                            }
                        }
                    }
                }
            }
            echo '<tr id="rmqtb' . $i . '">' . "\n";
            echo '<td><input type="button" class="ed_button" title="" value="' . $text . '"' . $style . '> <code>' . $value . '</code></td>';
            // loop about the post types, create html an values
            $pt_checkboxes = '';
            foreach ($this->get_post_types_for_js() as $post_type) {
                $pt_checked = '';
                if (isset($options['core_buttons'][$value][$post_type]) && 1 == $options['core_buttons'][$value][$post_type]) {
                    $pt_checked = ' checked="checked"';
                }
                $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' . parent::get_option_string() . '[core_buttons][' . $value . '][' . $post_type . ']" value="1"' . $pt_checked . '/></td>' . "\n";
            }
            echo $pt_checkboxes;
            echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
            echo '</tr>' . "\n";
            $i++;
        }
        // Convert new buttons array back into a comma-separated string
        $core_qt = implode(',', $core_buttons);
        ?>
		</table>
	<?php 
    }