Changeset 2210201
- Timestamp:
- 12/11/2019 03:16:14 PM (6 years ago)
- Location:
- easy-tinymce-editor-add-button/trunk
- Files:
-
- 5 edited
-
easy-tinymce-editor-add-button.php (modified) (2 diffs)
-
includes/Admin.php (modified) (4 diffs)
-
includes/Editor.php (modified) (2 diffs)
-
includes/Manager.php (modified) (2 diffs)
-
includes/templates/settings.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-tinymce-editor-add-button/trunk/easy-tinymce-editor-add-button.php
r2209319 r2210201 3 3 Plugin Name: Easy Tinymce Editor Add Button 4 4 Description: Simple add button tinyMCE editor 5 Version: 1.3.25 Version: 2.0.1 6 6 Author: TrubinE 7 7 Author URI: http://onwp.ru … … 39 39 $namespace = 'EasyTinymceEditorAddButton'; 40 40 $plugin_slug = 'easy-tinymce-editor-add-button'; 41 $version = ' 1.2.0';41 $version = '2.0.1'; 42 42 43 43 require_once plugin_dir_path(__FILE__) . 'ClassLoader.php'; -
easy-tinymce-editor-add-button/trunk/includes/Admin.php
r2117715 r2210201 7 7 private $version; 8 8 private $plugin_slug; 9 private $is_install; 9 10 private $ns = 'ete-buttons'; 10 11 private $options = [ … … 16 17 $this->version = $version; 17 18 $this->plugin_slug = $plugin_slug; 19 $this->is_install = Install::isModuleInstallDB(); 20 } 21 22 public function runInstall() 23 { 24 Install::runInstall(); 25 } 26 27 public function checkInstall($vars) 28 { 29 Install::checkInstall(); 30 } 31 32 public function noticeInstall() 33 { 34 Install::getTemplateInstall(); 18 35 } 19 36 … … 39 56 public function enqueue_vendor_global() 40 57 { 41 wp_localize_script('jquery', 'ETE_BUTTONS', get_option('ETE_buttons')); 42 } 58 $buttons = false; 43 59 44 /** 45 * Register settings 46 * 47 */ 48 public function register_settings() 49 { 50 foreach ($this->options as $option) { 51 register_setting($this->ns . '-group', $option, array($this, 'field_validation')); 60 if ($this->is_install) { 61 $buttons = Query::getAll();; 52 62 } 63 64 wp_localize_script('jquery', 'ETE_BUTTONS', $buttons); 53 65 } 54 66 55 67 56 /** 57 * Validation fields "ETE_buttons" 58 * 59 * @param $fields 60 * @return array 61 */ 62 public function field_validation($fields) 68 public function updateButtons() 63 69 { 64 if (is_array($fields)) { 65 foreach ($fields as $key => $field) { 66 $sanitize_title = sanitize_key($fields[$key]['title']); 70 if ((!empty($_POST['eteab_nonce']) && wp_verify_nonce($_POST['eteab_nonce'], 'eteab_nonce')) 71 && (!empty($_POST['eteab']) && $_POST['eteab'] === 'update')) { 67 72 68 if (empty($sanitize_title)) { 69 $sanitize_title = 'button_' . $key; 70 } 73 $buttons = !empty($_POST) ? $_POST['ETE_buttons'] : null; 71 74 72 $fields[$key]['title'] = $sanitize_title; 75 if (!empty($buttons) && is_array($buttons)) { 76 Install::import($buttons); 77 } 78 79 if (!empty($_POST['page'])) { 80 wp_redirect('/wp-admin/options-general.php?page=' . $_POST['page']); 81 die(); 73 82 } 74 83 } 75 76 return $fields;77 84 } 78 85 … … 101 108 public function settings_page() 102 109 { 103 require_once plugin_dir_path(__FILE__) . 'templates/settings.php'; 110 if ($this->is_install) { 111 require_once plugin_dir_path(__FILE__) . 'templates/settings.php'; 112 } else { 113 _e('Run install DB from "Easy Tinymce Editor Add Button" for full plugin operation!', 'easy-tinymce-editor-add-button'); 114 } 115 104 116 } 105 117 } -
easy-tinymce-editor-add-button/trunk/includes/Editor.php
r2209318 r2210201 13 13 $this->plugin_slug = $plugin_slug; 14 14 add_action('admin_print_footer_scripts', array($this, 'add_quicktags')); 15 }16 17 /**18 * Add admin editor css style19 *20 */21 public function enqueue_vendor()22 {23 wp_enqueue_style(24 $this->plugin_slug . '-css',25 plugins_url('css/style.css', __FILE__),26 array(),27 $this->version,28 false29 );30 15 } 31 16 … … 47 32 ETE_BUTTONS[i]['title'], // html id for the button 48 33 ETE_BUTTONS[i]['title'], // html value for the button 49 ETE_BUTTONS[i]['left '], // starting tag50 ETE_BUTTONS[i]['right '], // ending tag34 ETE_BUTTONS[i]['left_code'], // starting tag 35 ETE_BUTTONS[i]['right_code'], // ending tag 51 36 '', // shortcut access key for the button 52 ETE_BUTTONS[i]['left '] + ' ... ' + ETE_BUTTONS[i]['right'], // html title value for the button37 ETE_BUTTONS[i]['left_code'] + ' ... ' + ETE_BUTTONS[i]['right_code'], // html title value for the button 53 38 index++ // number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third 54 39 ); -
easy-tinymce-editor-add-button/trunk/includes/Manager.php
r1934790 r2210201 35 35 { 36 36 $admin = new \EasyTinymceEditorAddButton\includes\Admin($this->version, $this->plugin_slug); 37 $this->loader->add_action(' admin_init', $admin, 'register_settings');37 $this->loader->add_action('init', $admin, 'updateButtons'); 38 38 $this->loader->add_action('admin_menu', $admin, 'admin_menu'); 39 39 $this->loader->add_action('admin_enqueue_scripts', $admin, 'enqueue_vendor'); 40 40 $this->loader->add_action('admin_enqueue_scripts', $admin, 'enqueue_vendor_global'); 41 $this->loader->add_action('init', $admin, 'checkInstall'); 42 $this->loader->add_action('init', $admin, 'runInstall'); 43 $this->loader->add_action('admin_menu', $admin, 'noticeInstall'); 41 44 } 42 45 … … 47 50 private function define_editor_hooks() 48 51 { 49 $editor = new \EasyTinymceEditorAddButton\includes\Editor($this->version, $this->plugin_slug); 50 $this->loader->add_action('admin_enqueue_scripts', $editor, 'enqueue_vendor'); 52 (new \EasyTinymceEditorAddButton\includes\Editor($this->version, $this->plugin_slug)); 51 53 } 52 54 -
easy-tinymce-editor-add-button/trunk/includes/templates/settings.php
r2209318 r2210201 3 3 ?> 4 4 <h1><?php _e('Easy TinyMCE Editor Add Button', 'easy-tinymce-editor-add-button'); ?></h1> 5 <form method="post" action="options.php"> 6 <?php 7 settings_fields('ete-buttons-group'); 8 $buttons = get_option('ETE_buttons'); 9 ?> 5 <form method="post" action="options-general.php"> 6 <?php $buttons = \EasyTinymceEditorAddButton\includes\Query::getAll(); ?> 10 7 <div class="ete-buttons-list"> 11 8 <?php if (!empty($buttons)) { … … 23 20 type="text" 24 21 name="ETE_buttons[<?php echo $key; ?>][left]" 25 value="<?php echo htmlspecialchars($button['left ']); ?>"/>22 value="<?php echo htmlspecialchars($button['left_code']); ?>"/> 26 23 </label> 27 24 <label><?php _e('Right code: ', 'easy-tinymce-editor-add-button') ?> … … 29 26 type="text" 30 27 name="ETE_buttons[<?php echo $key; ?>][right]" 31 value="<?php echo htmlspecialchars($button['right ']); ?>"/>28 value="<?php echo htmlspecialchars($button['right_code']); ?>"/> 32 29 </label> 33 30 <a href="#" class="ete-buttons-remove"><?php _e('remove', 'easy-tinymce-editor-add-button') ?></a> … … 66 63 <input name="submit" id="submit" class="button button-primary" value="Сохранить изменения" type="submit"> 67 64 </p> 65 <input type="hidden" name="eteab" value="update"/> 66 <input type="hidden" name="page" value="easy-tinymce-editor-add-button"/> 67 <input type="hidden" name="eteab_nonce" 68 value="<?php echo wp_create_nonce('eteab_nonce'); ?>"/> 68 69 </form>
Note: See TracChangeset
for help on using the changeset viewer.