| @@ -1,251 +1,250 @@ | ||
| 1 | -<?php | |
| 2 | - /** | |
| 3 | - * Admin Class | |
| 4 | - * | |
| 5 | - * @package Wow_Plugin | |
| 6 | - * @subpackage | |
| 7 | - * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 9 | - * @since 1.0 | |
| 10 | - */ | |
| 11 | - | |
| 12 | - namespace wpcoder; | |
| 13 | - | |
| 14 | - if ( ! defined( 'ABSPATH' ) ) exit; | |
| 15 | - | |
| 16 | - class Wow_Admin_Class { | |
| 17 | - | |
| 18 | - private $arg; | |
| 19 | - | |
| 20 | - public function __construct( $arg ) { | |
| 21 | - $this->plugin_name = $arg['plugin_name']; | |
| 22 | - $this->plugin_menu = $arg['plugin_menu']; | |
| 23 | - $this->plugin_home_url = $arg['plugin_home_url']; | |
| 24 | - $this->plugin_version = $arg['plugin_version']; | |
| 25 | - $this->plugin_file = $arg['plugin_file']; | |
| 26 | - $this->plugin_slug = $arg['plugin_slug']; | |
| 27 | - $this->plugin_dir = $arg['plugin_dir']; | |
| 28 | - $this->plugin_url = $arg['plugin_url']; | |
| 29 | - $this->plugin_pref = $arg['plugin_pref']; | |
| 30 | - $this->author_url = $arg['author_url']; | |
| 31 | - $this->pro_url = $arg['pro_url']; | |
| 32 | - $this->shortcode = $arg['shortcode']; | |
| 33 | - | |
| 34 | - | |
| 35 | - | |
| 36 | - add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 ); | |
| 37 | - | |
| 38 | - add_action( 'admin_menu', array( $this, 'add_admin_page' ) ); | |
| 39 | - | |
| 40 | - add_filter( 'admin_footer_text', array( $this, 'rate_us' ) ); | |
| 41 | - | |
| 42 | - add_action( 'plugins_loaded', array( $this, 'plugin_check' ) ); | |
| 43 | - | |
| 44 | - | |
| 45 | - } | |
| 46 | - public function add_admin_page() { | |
| 47 | - $icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIi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gwIDE1eiIvPgo8L2c+Cjwvc3ZnPgo='; | |
| 48 | - | |
| 49 | - if( !class_exists( 'Wow_Company' ) ) { | |
| 50 | - add_menu_page( 'Wow Plugins', 'Wow Plugins', 'manage_options', 'wow-company', array( $this, 'admin_main_page' ), $icon ); | |
| 51 | - add_submenu_page( 'wow-company', 'About Wow Plugins', 'About', 'manage_options', 'wow-company' ); | |
| 52 | - add_submenu_page('wow-company', $this->plugin_name . ' version ' . $this->plugin_version, $this->plugin_menu, 'manage_options', $this->plugin_slug, array( $this, 'plugin_page' ) ); | |
| 53 | - } | |
| 54 | - else { | |
| 55 | - add_submenu_page('wow-company', $this->plugin_name . ' version ' . $this->plugin_version, $this->plugin_menu, 'manage_options', $this->plugin_slug, array( $this, 'plugin_page' ) ); | |
| 56 | - } | |
| 57 | - | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Admin Class | |
| 4 | + * | |
| 5 | + * @package Wow_Plugin | |
| 6 | + * @subpackage | |
| 7 | + * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 9 | + * @since 1.0 | |
| 10 | + */ | |
| 11 | + | |
| 12 | +namespace wpcoder; | |
| 13 | + | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; | |
| 16 | +} | |
| 17 | + | |
| 18 | +class Wow_Admin_Class { | |
| 19 | + | |
| 20 | + private $arg; | |
| 21 | + | |
| 22 | + public function __construct( $arg ) { | |
| 23 | + $this->plugin_name = $arg['plugin_name']; | |
| 24 | + $this->plugin_menu = $arg['plugin_menu']; | |
| 25 | + $this->plugin_home_url = $arg['plugin_home_url']; | |
| 26 | + $this->plugin_version = $arg['plugin_version']; | |
| 27 | + $this->plugin_file = $arg['plugin_file']; | |
| 28 | + $this->plugin_slug = $arg['plugin_slug']; | |
| 29 | + $this->plugin_dir = $arg['plugin_dir']; | |
| 30 | + $this->plugin_url = $arg['plugin_url']; | |
| 31 | + $this->plugin_pref = $arg['plugin_pref']; | |
| 32 | + $this->author_url = $arg['author_url']; | |
| 33 | + $this->pro_url = $arg['pro_url']; | |
| 34 | + $this->shortcode = $arg['shortcode']; | |
| 35 | + | |
| 36 | + | |
| 37 | + add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 ); | |
| 38 | + add_action( 'admin_menu', array( $this, 'add_admin_page' ) ); | |
| 39 | + add_filter( 'admin_footer_text', array( $this, 'rate_us' ) ); | |
| 40 | + add_action( 'plugins_loaded', array( $this, 'plugin_check' ) ); | |
| 41 | + add_action( 'wp_ajax_wp_coder_message', array( $this, 'wow_message_callback' ) ); | |
| 42 | + | |
| 43 | + | |
| 44 | + } | |
| 45 | + | |
| 46 | + public function add_admin_page() { | |
| 47 | + $icon = | |
| 48 | + 'data:image/svg+xml;base64, PHN2ZyB3aWR0aD0iNTEycHgiIGhlaWdodD0iNTEycHgiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPldPVyBMT0dPPC90aXRsZT4KICAgIDxkZWZzPgogICAgICAgIDxsaW5lYXJHcmFkaWVudCB4MT0iNTAlIiB5MT0iMCUiIHgyPSI1MCUiIHkyPSIxMDAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNGN0NDNUYiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0U4NkUyQyIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMT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0NS41NDMwNSw0NTYgMjU2LDQ1NiBaIiBpZD0iT3ZhbCIgc3Ryb2tlPSJ1cmwoI2xpbmVhckdyYWRpZW50LTIpIiBzdHJva2Utd2lkdGg9IjI4IiBzdHJva2UtZGFzaGFycmF5PSIxMTU1LjUyLDk5OTk5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyNTYuMDAwMDAwLCAyNTYuMDAwMDAwKSByb3RhdGUoLTEzMi4wMDAwMDApIHRyYW5zbGF0ZSgtMjU2LjAwMDAwMCwgLTI1Ni4wMDAwMDApICI+PC9wYXRoPgogICAgPC9nPgo8L3N2Zz4='; | |
| 49 | + | |
| 50 | + if ( ! class_exists( 'Wow_Company' ) ) { | |
| 51 | + add_menu_page( 'Wow Plugins', 'Wow Plugins', 'manage_options', 'wow-company', array( | |
| 52 | + $this, | |
| 53 | + 'admin_main_page' | |
| 54 | + ), $icon ); | |
| 55 | + add_submenu_page( 'wow-company', 'About Wow Plugins', 'About', 'manage_options', 'wow-company' ); | |
| 56 | + add_submenu_page( 'wow-company', $this->plugin_name . ' version ' . $this->plugin_version, $this->plugin_menu, 'manage_options', $this->plugin_slug, array( | |
| 57 | + $this, | |
| 58 | + 'plugin_page' | |
| 59 | + ) ); | |
| 60 | + } else { | |
| 61 | + add_submenu_page( 'wow-company', $this->plugin_name . ' version ' . $this->plugin_version, $this->plugin_menu, 'manage_options', $this->plugin_slug, array( | |
| 62 | + $this, | |
| 63 | + 'plugin_page' | |
| 64 | + ) ); | |
| 58 | 65 | } |
| 59 | - | |
| 60 | - public function admin_main_page() { | |
| 61 | - require_once plugin_dir_path( __FILE__ ) . 'general/main.php'; | |
| 66 | + | |
| 67 | + } | |
| 68 | + | |
| 69 | + public function admin_main_page() { | |
| 70 | + require_once plugin_dir_path( __FILE__ ) . 'general/main.php'; | |
| 71 | + wp_enqueue_style( 'wow-page', plugin_dir_url(__FILE__) .'general/style.css'); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public function plugin_page() { | |
| 75 | + global $typenow; | |
| 76 | + $typenow = $this->plugin_slug; | |
| 77 | + require_once plugin_dir_path( __FILE__ ) . 'partials/main.php'; | |
| 78 | + self:: admin_style_script(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public function admin_style_script() { | |
| 82 | + wp_enqueue_style( $this->plugin_slug . '-admin', $this->plugin_url . 'assets/css/admin.css', false, $this->plugin_version ); | |
| 83 | + wp_enqueue_style( $this->plugin_slug . '-style', $this->plugin_url . 'assets/css/style.css', false, $this->plugin_version ); | |
| 84 | + | |
| 85 | + wp_enqueue_script( 'jquery-ui-tooltip' ); | |
| 86 | + wp_enqueue_media(); | |
| 87 | + wp_enqueue_script( 'code-editor' ); | |
| 88 | + wp_enqueue_style( 'code-editor' ); | |
| 89 | + wp_enqueue_script( 'htmlhint' ); | |
| 90 | + wp_enqueue_script( 'csslint' ); | |
| 91 | + wp_enqueue_script( 'jshint' ); | |
| 92 | + | |
| 93 | + wp_enqueue_script( $this->plugin_slug . '-script', $this->plugin_url . 'assets/js/script.js', array( 'jquery' ), $this->plugin_version ); | |
| 94 | + wp_enqueue_script( $this->plugin_slug . '-codemirror', $this->plugin_url . 'assets/js/script-codemirror.js', array( 'code-editor' ), $this->plugin_version ); | |
| 95 | + wp_enqueue_script( $this->plugin_slug . '-admin', $this->plugin_url . 'assets/js/admin.js', array( 'jquery' ), $this->plugin_version ); | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + public function action_links( $actions, $plugin_file ) { | |
| 100 | + if ( false === strpos( $plugin_file, $this->plugin_file ) ) { | |
| 101 | + return $actions; | |
| 62 | 102 | } |
| 63 | - | |
| 64 | - public function plugin_page() { | |
| 65 | - global $typenow; | |
| 66 | - $typenow = $this->plugin_slug; | |
| 67 | - require_once plugin_dir_path( __FILE__ ) . 'partials/main.php'; | |
| 68 | - if( $current_tab == 'add_new') { | |
| 69 | - self:: admin_style_script(); | |
| 70 | - } | |
| 71 | - } | |
| 72 | - | |
| 73 | - public function admin_style_script() { | |
| 74 | - wp_enqueue_style( $this->plugin_slug . '-admin', $this->plugin_url . 'assets/css/admin.css', false, $this->plugin_version ); | |
| 75 | - wp_enqueue_style( $this->plugin_slug . '-style', $this->plugin_url . 'assets/css/style.css', false, $this->plugin_version ); | |
| 76 | - | |
| 77 | - wp_enqueue_script( 'jquery-ui-tooltip' ); | |
| 78 | - wp_enqueue_media (); | |
| 79 | - wp_enqueue_script( 'code-editor' ); | |
| 80 | - wp_enqueue_style( 'code-editor' ); | |
| 81 | - wp_enqueue_script( 'htmlhint' ); | |
| 82 | - wp_enqueue_script( 'csslint' ); | |
| 83 | - wp_enqueue_script( 'jshint' ); | |
| 84 | - | |
| 85 | - | |
| 86 | - wp_enqueue_script( $this->plugin_slug . '-script', $this->plugin_url . 'assets/js/script.js', array('jquery'), $this->plugin_version ); | |
| 87 | - wp_enqueue_script( $this->plugin_slug . '-codemirror', $this->plugin_url . 'assets/js/script-codemirror.js', array('code-editor'), $this->plugin_version ); | |
| 88 | - wp_enqueue_script( $this->plugin_slug . '-admin', $this->plugin_url . 'assets/js/admin.js', array('jquery'), $this->plugin_version ); | |
| 89 | - | |
| 90 | - } | |
| 91 | - | |
| 92 | - public function action_links( $actions, $plugin_file ) { | |
| 93 | - if( false === strpos( $plugin_file, $this->plugin_file ) ) { | |
| 94 | - return $actions; | |
| 95 | - } | |
| 96 | - $settings_link = '<a href="admin.php?page=' . $this->plugin_slug . '">' . __( 'Settings', $this->plugin_pref ) . '</a>'; | |
| 97 | - array_unshift( $actions, $settings_link ); | |
| 98 | - return $actions; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public function rate_us( $footer_text ) { | |
| 102 | - global $typenow; | |
| 103 | - if ( $typenow == $this->plugin_slug ) { | |
| 104 | - $rate_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">' . $this->plugin_name . '</a>! Please <a href="%2$s" target="_blank">rate us on WordPress</a>', $this->plugin_pref ), | |
| 103 | + $settings_link = '<a href="admin.php?page=' . $this->plugin_slug . '">' . __( 'Settings', $this->plugin_pref ) . '</a>'; | |
| 104 | + array_unshift( $actions, $settings_link ); | |
| 105 | + | |
| 106 | + return $actions; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public function rate_us( $footer_text ) { | |
| 110 | + global $typenow; | |
| 111 | + if ( $typenow == $this->plugin_slug ) { | |
| 112 | + $rate_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">' . $this->plugin_name . '</a>! Please <a href="%2$s" target="_blank">rate us on WordPress</a>', $this->plugin_pref ), | |
| 105 | 113 | $this->plugin_home_url, |
| 106 | 114 | $this->plugin_home_url . 'reviews/?rate=5#new-post' |
| 107 | - ); | |
| 108 | - return str_replace( '</span>', '', $footer_text ) . ' | ' . $rate_text . '</span>'; | |
| 109 | - } else { | |
| 110 | - return $footer_text; | |
| 111 | - } | |
| 112 | - } | |
| 113 | - | |
| 114 | - static function tooltip( $arg ) { | |
| 115 | - $tooltip = ''; | |
| 116 | - foreach ( $arg as $key => $value ) { | |
| 117 | - if( $key == 'title' ) { | |
| 118 | - $tooltip .= $value . '<p/>'; | |
| 119 | - } | |
| 120 | - elseif ( $key == 'ul' ) { | |
| 121 | - $tooltip .= '<ul>'; | |
| 122 | - $arr = $value; | |
| 123 | - foreach ( $arr as $val ) { | |
| 124 | - $tooltip .= '<li>' . $val . '</li>'; | |
| 125 | - } | |
| 126 | - $tooltip .= '</ul>'; | |
| 127 | - } | |
| 128 | - else { | |
| 129 | - $tooltip .= $value; | |
| 130 | - } | |
| 131 | - } | |
| 132 | - $tooltip = "<span class='wow-help dashicons dashicons-editor-help' title='" . $tooltip . "'></span>"; | |
| 133 | - return $tooltip; | |
| 115 | + ); | |
| 116 | + | |
| 117 | + return str_replace( '</span>', '', $footer_text ) . ' | ' . $rate_text . '</span>'; | |
| 118 | + } else { | |
| 119 | + return $footer_text; | |
| 134 | 120 | } |
| 135 | - | |
| 136 | - static function option( $arg ) { | |
| 137 | - $id = isset( $arg['id'] ) ? $arg['id'] : null; | |
| 138 | - $name = isset( $arg['name'] ) ? $arg['name'] : ''; | |
| 139 | - $type = isset( $arg['type'] ) ? $arg['type'] : ''; | |
| 140 | - $func = !empty( $arg['func'] ) ? ' onchange="'.$arg['func'].'();"' : ''; | |
| 141 | - $options = isset( $arg['option'] ) ? $arg['option'] : ''; | |
| 142 | - $val = $arg['val']; | |
| 143 | - $separator = isset($arg['sep']) ? $arg['sep'] : ''; | |
| 144 | - // create radio fields | |
| 145 | - if ($type == 'radio'){ | |
| 146 | - $option = ''; | |
| 147 | - foreach ($options as $key => $value){ | |
| 148 | - $select = ($key == $val) ? 'checked="checked"' : ''; | |
| 149 | - $option .= '<input name="param['.$name.']" type="radio" value="'.$key.'" id="wow_'.$id.'_'.$key.'" '.$select.$func.'><label for="wow_'.$id.'_'.$key.'"> '.$value.'</label>'.$separator; | |
| 121 | + } | |
| 122 | + | |
| 123 | + static function tooltip( $arg ) { | |
| 124 | + $tooltip = ''; | |
| 125 | + foreach ( $arg as $key => $value ) { | |
| 126 | + if ( $key == 'title' ) { | |
| 127 | + $tooltip .= $value . '<p/>'; | |
| 128 | + } elseif ( $key == 'ul' ) { | |
| 129 | + $tooltip .= '<ul>'; | |
| 130 | + $arr = $value; | |
| 131 | + foreach ( $arr as $val ) { | |
| 132 | + $tooltip .= '<li>' . $val . '</li>'; | |
| 150 | 133 | } |
| 151 | - $field = $option; | |
| 134 | + $tooltip .= '</ul>'; | |
| 135 | + } else { | |
| 136 | + $tooltip .= $value; | |
| 152 | 137 | } |
| 153 | - | |
| 154 | - // create checkbox field | |
| 155 | - elseif ($type == 'checkbox'){ | |
| 156 | - $select = !empty($val) ? 'checked="checked"' : ''; | |
| 157 | - $field = '<input type="checkbox" '.$select.$func.' id="wow_'.$id.'">'.$separator; | |
| 158 | - $field .= '<input type="hidden" name="param['.$name.']" value="">'; | |
| 138 | + } | |
| 139 | + $tooltip = "<span class='wow-help dashicons dashicons-editor-help' title='" . $tooltip . "'></span>"; | |
| 140 | + | |
| 141 | + return $tooltip; | |
| 142 | + } | |
| 143 | + | |
| 144 | + static function option( $arg ) { | |
| 145 | + $id = isset( $arg['id'] ) ? $arg['id'] : null; | |
| 146 | + $name = isset( $arg['name'] ) ? $arg['name'] : ''; | |
| 147 | + $type = isset( $arg['type'] ) ? $arg['type'] : ''; | |
| 148 | + $func = ! empty( $arg['func'] ) ? ' onchange="' . $arg['func'] . '();"' : ''; | |
| 149 | + $options = isset( $arg['option'] ) ? $arg['option'] : ''; | |
| 150 | + $val = $arg['val']; | |
| 151 | + $separator = isset( $arg['sep'] ) ? $arg['sep'] : ''; | |
| 152 | + // create radio fields | |
| 153 | + if ( $type == 'radio' ) { | |
| 154 | + $option = ''; | |
| 155 | + foreach ( $options as $key => $value ) { | |
| 156 | + $select = ( $key == $val ) ? 'checked="checked"' : ''; | |
| 157 | + $option .= '<input name="param[' . $name . ']" type="radio" value="' . $key . '" id="wow_' . $id . '_' . $key . '" ' . $select . $func . '><label for="wow_' . $id . '_' . $key . '"> ' . $value . '</label>' . $separator; | |
| 159 | 158 | } |
| 160 | - | |
| 161 | - // create text field | |
| 162 | - elseif ($type == 'text'){ | |
| 163 | - $option = ''; | |
| 164 | - if ( is_array( $options ) ) { | |
| 165 | - foreach ($options as $key => $value){ | |
| 166 | - $option .= ' ' . $key . '="' . $value . '"'; | |
| 167 | - } | |
| 168 | - } | |
| 169 | - $field = '<input name="param[' . $name . ']" type="text" value="' . $val . '" id="wow_' . $id . '"' . $func . $option .'>'.$separator; | |
| 159 | + $field = $option; | |
| 160 | + } // create checkbox field | |
| 161 | + elseif ( $type == 'checkbox' ) { | |
| 162 | + $select = ! empty( $val ) ? 'checked="checked"' : ''; | |
| 163 | + $field = '<input type="checkbox" ' . $select . $func . ' id="wow_' . $id . '">' . $separator; | |
| 164 | + $field .= '<input type="hidden" name="param[' . $name . ']" value="">'; | |
| 165 | + } // create text field | |
| 166 | + elseif ( $type == 'text' ) { | |
| 167 | + $option = ''; | |
| 168 | + if ( is_array( $options ) ) { | |
| 169 | + foreach ( $options as $key => $value ) { | |
| 170 | + $option .= ' ' . $key . '="' . $value . '"'; | |
| 171 | + } | |
| 170 | 172 | } |
| 171 | - | |
| 172 | - // create number field | |
| 173 | - elseif ($type == 'number'){ | |
| 174 | - $option = ''; | |
| 175 | - if ( is_array( $options ) ) { | |
| 176 | - foreach ($options as $key => $value){ | |
| 177 | - $option .= ' ' . $key . '="' . $value . '"'; | |
| 178 | - } | |
| 173 | + $field = '<input name="param[' . $name . ']" type="text" value="' . $val . '" id="wow_' . $id . '"' . $func . $option . '>' . $separator; | |
| 174 | + } // create number field | |
| 175 | + elseif ( $type == 'number' ) { | |
| 176 | + $option = ''; | |
| 177 | + if ( is_array( $options ) ) { | |
| 178 | + foreach ( $options as $key => $value ) { | |
| 179 | + $option .= ' ' . $key . '="' . $value . '"'; | |
| 179 | 180 | } |
| 180 | - $field = '<input name="param['.$name.']" type="number" value="'.$val.'" id="wow_'.$id.'"' . $func . $option . '>'.$separator; | |
| 181 | 181 | } |
| 182 | - | |
| 183 | - // create color field | |
| 184 | - elseif ($type == 'color'){ | |
| 185 | - $field = '<input name="param['.$name.']" type="text" value="'.$val.'" class="wp-color-picker-field" data-alpha="true" id="wow_'.$id.'">'.$separator; | |
| 182 | + $field = '<input name="param[' . $name . ']" type="number" value="' . $val . '" id="wow_' . $id . '"' . $func . $option . '>' . $separator; | |
| 183 | + } // create color field | |
| 184 | + elseif ( $type == 'color' ) { | |
| 185 | + $field = '<input name="param[' . $name . ']" type="text" value="' . $val . '" class="wp-color-picker-field" data-alpha="true" id="wow_' . $id . '">' . $separator; | |
| 186 | + } // create select field | |
| 187 | + elseif ( $type == 'select' ) { | |
| 188 | + $option = ''; | |
| 189 | + foreach ( $options as $key => $value ) { | |
| 190 | + $select = ( $key == $val ) ? 'selected="selected"' : ''; | |
| 191 | + $option .= '<option value="' . $key . '" ' . $select . '>' . $value . '</option>'; | |
| 186 | 192 | } |
| 187 | - | |
| 188 | - // create select field | |
| 189 | - elseif ($type == 'select'){ | |
| 190 | - $option = ''; | |
| 191 | - foreach ($options as $key => $value){ | |
| 192 | - $select = ($key == $val) ? 'selected="selected"' : ''; | |
| 193 | - $option .= '<option value="'.$key.'" '.$select.'>'.$value.'</option>'; | |
| 194 | - } | |
| 195 | - $field = '<select name="param['.$name.']"'.$func.' id="wow_'.$id.'">'; | |
| 196 | - $field .= $option; | |
| 197 | - $field .= '</select>' . $separator; | |
| 198 | - } | |
| 199 | - | |
| 200 | - // create editor field | |
| 201 | - elseif ($type == 'editor'){ | |
| 202 | - $settings = array( | |
| 193 | + $field = '<select name="param[' . $name . ']"' . $func . ' id="wow_' . $id . '">'; | |
| 194 | + $field .= $option; | |
| 195 | + $field .= '</select>' . $separator; | |
| 196 | + } // create editor field | |
| 197 | + elseif ( $type == 'editor' ) { | |
| 198 | + $settings = array( | |
| 203 | 199 | 'wpautop' => 0, |
| 204 | - 'textarea_name' => 'param['.$name.']', | |
| 200 | + 'textarea_name' => 'param[' . $name . ']', | |
| 205 | 201 | 'textarea_rows' => 15, |
| 206 | - ); | |
| 207 | - $field = wp_editor( $val, $id, $settings ); | |
| 208 | - } | |
| 209 | - | |
| 210 | - // create textarea field | |
| 211 | - elseif ($type == 'textarea'){ | |
| 212 | - $field = '<textarea name="param['.$name.']" id="wow_'.$id.'">'.$val.'</textarea>'.$separator; | |
| 202 | + ); | |
| 203 | + $field = wp_editor( $val, $id, $settings ); | |
| 204 | + } // create textarea field | |
| 205 | + elseif ( $type == 'textarea' ) { | |
| 206 | + $field = '<textarea name="param[' . $name . ']" id="wow_' . $id . '">' . esc_html( $val ) . '</textarea>' . $separator; | |
| 207 | + | |
| 208 | + } | |
| 209 | + | |
| 210 | + return $field; | |
| 211 | + } | |
| 212 | + | |
| 213 | + public function plugin_check() { | |
| 214 | + if ( isset( $_POST[ $this->plugin_slug . '_nonce' ] ) ) { | |
| 215 | + if ( ! empty( $_POST ) && wp_verify_nonce( $_POST[ $this->plugin_slug . '_nonce' ], $this->plugin_slug . '_action' ) && current_user_can( 'manage_options' ) ) { | |
| 216 | + self:: save_data(); | |
| 213 | 217 | } |
| 214 | - | |
| 215 | - return $field; | |
| 216 | 218 | } |
| 217 | - | |
| 218 | - public function plugin_check() { | |
| 219 | - if ( isset( $_POST[$this->plugin_slug . '_nonce'] ) ) { | |
| 220 | - if ( !empty( $_POST ) && wp_verify_nonce( $_POST[$this->plugin_slug . '_nonce'], $this->plugin_slug . '_action' ) && current_user_can( 'manage_options' ) ) { | |
| 221 | - self:: save_data(); | |
| 222 | - } | |
| 219 | + } | |
| 220 | + | |
| 221 | + public function save_data() { | |
| 222 | + global $wpdb; | |
| 223 | + $save_class = __NAMESPACE__ . '\\Wow_DB_Update'; | |
| 224 | + $objItem = new $save_class( $this->plugin_dir, $this->plugin_slug ); | |
| 225 | + $add = ( isset( $_REQUEST['add'] ) ) ? absint( $_REQUEST['add'] ) : ''; | |
| 226 | + $data = ( isset( $_REQUEST['data'] ) ) ? sanitize_text_field( $_REQUEST['data'] ) : ''; | |
| 227 | + $page = sanitize_text_field( $_REQUEST['page'] ); | |
| 228 | + $tool_id = absint( $_POST['tool_id'] ); | |
| 229 | + $info = array(); | |
| 230 | + $info['id'] = $tool_id; | |
| 231 | + $info['title'] = sanitize_text_field( $_POST['title'] ); | |
| 232 | + $info['param'] = $_POST['param']; | |
| 233 | + if ( isset( $_POST['submit'] ) ) { | |
| 234 | + if ( absint( $_POST['add'] ) == '1' ) { | |
| 235 | + $objItem->addNewItem( $data, $info ); | |
| 236 | + header( 'Location:admin.php?page=' . $page . '&tab=add_new&act=update&id=' . $tool_id . '&info=saved' ); | |
| 237 | + exit; | |
| 238 | + } elseif ( absint( $_POST['add'] ) == '2' ) { | |
| 239 | + $objItem->updItem( $data, $info ); | |
| 240 | + header( 'Location:admin.php?page=' . $page . '&tab=add_new&act=update&id=' . $tool_id . '&info=update' ); | |
| 241 | + exit; | |
| 223 | 242 | } |
| 224 | 243 | } |
| 225 | - | |
| 226 | - public function save_data(){ | |
| 227 | - global $wpdb; | |
| 228 | - $save_class = __NAMESPACE__ . '\\Wow_DB_Update'; | |
| 229 | - $objItem = new $save_class( $this->plugin_dir, $this->plugin_slug ); | |
| 230 | - $add = ( isset( $_REQUEST['add'] ) ) ? absint( $_REQUEST['add'] ) : ''; | |
| 231 | - $data = ( isset( $_REQUEST['data'] ) ) ? sanitize_text_field( $_REQUEST['data'] ) : ''; | |
| 232 | - $page = sanitize_text_field( $_REQUEST['page'] ); | |
| 233 | - $tool_id = absint( $_POST['tool_id'] ); | |
| 234 | - $info = array(); | |
| 235 | - $info['id'] = $tool_id; | |
| 236 | - $info['title'] = sanitize_text_field( $_POST['title'] ); | |
| 237 | - $info['param'] = $_POST['param']; | |
| 238 | - if ( isset( $_POST['submit'] ) ) { | |
| 239 | - if ( absint( $_POST['add'] ) == '1') { | |
| 240 | - $objItem->addNewItem( $data, $info ); | |
| 241 | - header( 'Location:admin.php?page=' . $page . '&tab=add_new&act=update&id=' . $tool_id . '&info=saved' ); | |
| 242 | - exit; | |
| 243 | - } | |
| 244 | - elseif ( absint($_POST['add'] ) == '2' ) { | |
| 245 | - $objItem->updItem( $data, $info ); | |
| 246 | - header( 'Location:admin.php?page=' . $page . '&tab=add_new&act=update&id=' . $tool_id . '&info=update' ); | |
| 247 | - exit; | |
| 248 | - } | |
| 249 | - } | |
| 250 | - } | |
| 251 | - } | |
| 244 | + } | |
| 245 | + | |
| 246 | + public function wow_message_callback() { | |
| 247 | + update_option( 'wp_coder_message', 'read' ); | |
| 248 | + wp_die(); | |
| 249 | + } | |
| 250 | +} | |