| @@ -11,8 +11,10 @@ | ||
| 11 | 11 | protected $plugin_url; |
| 12 | 12 | protected $plugin_path; |
| 13 | 13 | protected $version; |
| 14 | 14 | |
| 15 | + protected $url; // pageURL | |
| 16 | + | |
| 15 | 17 | protected $networks; |
| 16 | 18 | protected $admin; |
| 17 | 19 | |
| 18 | 20 | public function __construct() |
| @@ -33,28 +35,44 @@ | ||
| 33 | 35 | |
| 34 | 36 | if (! is_admin()) |
| 35 | 37 | $hook_bool = collections::setupHooks(); |
| 36 | 38 | |
| 37 | - add_action('admin_menu', array($this, 'admin_menu') ); | |
| 39 | + //add_action('admin_menu', array($this, 'admin_menu') ); | |
| 38 | 40 | add_action('admin_enqueue_scripts', array($this, 'admin_styles') ); |
| 39 | 41 | |
| 42 | + // load admin pages, after MB. | |
| 43 | + add_filter('maxbuttons/plugin/admin_pages', array($this, 'admin_menu')); | |
| 44 | + | |
| 40 | 45 | add_action('add_meta_boxes', array($this, 'meta_boxes'), 10, 2 ); |
| 41 | 46 | add_action('save_post', array($this, 'save_meta_boxes'), 10, 3 ); |
| 42 | 47 | |
| 43 | 48 | add_action('wp_enqueue_scripts', array($this, 'front_scripts') ); |
| 44 | 49 | |
| 45 | - add_action('wp_enqueue_scripts', array($this, 'front_scripts') ); | |
| 50 | + add_shortcode('maxsocial', array($this->admin()->namespaceit('collections'), 'shortcode') ); | |
| 46 | 51 | |
| 47 | - add_shortcode('maxsocial', array($this->admin()->namespaceit('collections'), 'shortcode') ); | |
| 48 | 52 | add_action('maxbuttons/ajax/save_collection', array( $this->admin()->namespaceit('collections'), 'ajax_save') ); |
| 53 | + add_action('maxbuttons/ajax/remove-collection', array( $this->admin()->namespaceit('collections'), 'ajax_remove_collection') ); | |
| 54 | + | |
| 49 | 55 | add_action('maxbuttons/ajax/refreshblock', array($this->admin()->namespaceit('collections'), 'ajax_refreshblock') ); |
| 50 | 56 | add_action('maxbuttons/ajax/get_presets', array($this->admin()->namespaceit('collections'), 'ajax_getpresets') ); |
| 51 | 57 | add_action('maxbuttons/ajax/set_preset', array($this->admin()->namespaceit('collections'), 'ajax_setpreset') ); |
| 52 | 58 | |
| 59 | + add_action('maxbuttons/ajax/network-settings', array($this->networks(), 'ajax_networksettings') ); | |
| 60 | + add_action('maxbuttons/ajax/save-network', array($this->networks(), 'ajax_savenetwork') ); | |
| 61 | + add_action('maxbuttons/ajax/remove-networksettings', array($this->networks(), 'ajax_removesettings')); | |
| 62 | + add_action('maxbuttons/ajax/show-customnetworks', array($this->networks(), 'ajax_showcustomnetworks')); | |
| 63 | + add_action('maxbuttons/ajax/import-customnetworks', array($this->networks(), 'ajax_importcustomnetworks')); | |
| 64 | + | |
| 53 | 65 | // FRONT AJAX |
| 54 | 66 | add_action('wp_ajax_mbsocial_get_count', array($this->admin()->namespaceit("collections"), "ajax_action_front")); // front end for all users |
| 55 | 67 | add_action('wp_ajax_nopriv_mbsocial_get_count', array($this->admin()->namespaceit("collections"), "ajax_action_front")); |
| 56 | 68 | |
| 69 | + remove_action('admin_init', array(maxUtils::namespaceit('maxAdmin'), 'do_review_notice')); | |
| 70 | + add_action('admin_init', array($this->admin(), 'do_review_notice')); | |
| 71 | + add_action('maxbuttons/ajax/mbsocial_review_notice_status', array($this->admin(), 'save_review_notice')); | |
| 72 | + | |
| 73 | + add_action('wp_ajax_maxbuttons_social_css', array($this->admin()->namespaceit('collections'), 'outputFileCSS')); | |
| 74 | + add_action('wp_ajax_nopriv_maxbuttons_social_css', array($this->admin()->namespaceit('collections'), 'outputFileCSS')); | |
| 57 | 75 | //add_filter('mb-block-paths', array($this, 'block_templates')); |
| 58 | 76 | |
| 59 | 77 | } |
| 60 | 78 | |
| @@ -161,9 +179,9 @@ | ||
| 161 | 179 | |
| 162 | 180 | return $this->admin; |
| 163 | 181 | } |
| 164 | 182 | |
| 165 | - public function admin_menu () | |
| 183 | + public function admin_menu ($admin_pages) | |
| 166 | 184 | { |
| 167 | 185 | |
| 168 | 186 | $page_title = __('WordPress Share Buttons', 'mb-social'); |
| 169 | 187 | $menu_title = __('WordPress Share Buttons', 'mb-social'); |
| @@ -173,16 +191,26 @@ | ||
| 173 | 191 | $function = array($this, 'load_admin_page'); |
| 174 | 192 | $icon_url = $this->plugin_url . 'images/mb-social-icon.png'; |
| 175 | 193 | $submenu_function = array($this, 'load_admin_page'); |
| 176 | 194 | |
| 177 | - add_menu_page($page_title, $menu_title, $admin_capability, $menu_slug, $function, $icon_url, 81); | |
| 195 | + $admin_pages[] = add_menu_page($page_title, $menu_title, $admin_capability, $menu_slug, $function, $icon_url, 82); | |
| 178 | 196 | |
| 197 | + if (Install::isPro()) | |
| 198 | + { | |
| 199 | + $page_title = __('Settings', 'mb-social'); | |
| 200 | + $submenu_slug = 'maxbuttons-social-settings'; | |
| 201 | + $function = array($this, 'load_settings_page'); | |
| 202 | + $admin_pages[] = add_submenu_page($menu_slug, $page_title, $page_title, $admin_capability, $submenu_slug, $function); | |
| 203 | + } | |
| 204 | + | |
| 205 | + return $admin_pages; | |
| 179 | 206 | } |
| 180 | 207 | |
| 181 | 208 | public function admin_styles($hook) |
| 182 | 209 | { |
| 183 | - wp_register_style('mbsocial-global', $this->plugin_url . 'css/global-admin.css', array(), $this->version); | |
| 184 | 210 | |
| 211 | + wp_register_style('mbsocial-global', $this->plugin_url . 'css/global-admin.css', array(), $this->version); | |
| 212 | + | |
| 185 | 213 | if ( strpos($hook,'maxbuttons-social') === false ) |
| 186 | 214 | return; |
| 187 | 215 | |
| 188 | 216 | wp_enqueue_style('mbsocial-admin', $this->plugin_url . 'css/admin.css', array(), $this->version); |
| @@ -187,17 +215,29 @@ | ||
| 187 | 215 | |
| 188 | 216 | wp_enqueue_style('mbsocial-admin', $this->plugin_url . 'css/admin.css', array(), $this->version); |
| 189 | 217 | |
| 190 | 218 | if (Install::isPro()) |
| 219 | + { | |
| 191 | 220 | $deps = array('maxbuttons-pro-init','maxbuttons-ajax', 'mb-media-button', 'jquery-ui-sortable'); // pro init |
| 221 | + wp_register_script('maxbuttons-mbcustom', $this->plugin_url . 'js/maxbuttons-custom.js', $deps, $this->version, true); | |
| 222 | + wp_enqueue_script('maxbuttons-mbcustom'); | |
| 223 | + | |
| 224 | + wp_register_script('mbsocial-icons', $this->plugin_url . 'js/images.js', $deps, $this->version, true); | |
| 225 | + wp_enqueue_script('mbsocial-icons'); | |
| 226 | + | |
| 227 | + $deps[] = 'mbsocial-icons'; | |
| 228 | + } | |
| 192 | 229 | else |
| 230 | + { | |
| 193 | 231 | $deps = array('maxbutton-js-init', 'maxbuttons-ajax', 'mb-media-button', 'jquery-ui-sortable'); // free init |
| 194 | - | |
| 232 | + } | |
| 195 | 233 | wp_register_script('maxbuttons-social', $this->plugin_url . 'js/maxbuttons-social.js', $deps , $this->version, true); |
| 196 | 234 | wp_enqueue_script('maxbuttons-social'); |
| 197 | 235 | |
| 198 | - //wp_register_style('mbsocial-buttons', $this->plugin_url . 'css/buttons.css', array(), $this->version); | |
| 199 | - //wp_enqueue_style('mbsocial-buttons'); | |
| 236 | + | |
| 237 | + wp_register_script('mbsocial-editor', $this->plugin_url . 'js/network-editor.js', $deps, $this->version, true); | |
| 238 | + wp_enqueue_script('mbsocial-editor'); | |
| 239 | + | |
| 200 | 240 | MB()->load_media_script(); |
| 201 | 241 | |
| 202 | 242 | wp_register_style('nucleo_icons', $this->plugin_url . 'libraries/nucleo_icons/nucleo_icons.css', array(), $this->version); |
| 203 | 243 | wp_enqueue_style('nucleo_icons'); |
| @@ -207,12 +247,14 @@ | ||
| 207 | 247 | { |
| 208 | 248 | wp_register_script('mbsocial_front', $this->plugin_url . 'js/social-front.js', array('jquery'), |
| 209 | 249 | $this->version, true); |
| 210 | 250 | |
| 251 | + wp_localize_script('mbsocial_front','mbsocial', array('ajaxurl' => admin_url( 'admin-ajax.php' ))); | |
| 252 | + | |
| 211 | 253 | wp_register_style('mbsocial-buttons', $this->plugin_url . 'css/buttons.css'); |
| 212 | 254 | |
| 213 | - wp_register_style('nucleo_icons', $this->plugin_url . 'libraries/nucleo_icons/nucleo_icons.css', array(), $this->version); | |
| 214 | - wp_enqueue_style('nucleo_icons'); | |
| 255 | + //wp_register_style('nucleo_icons', $this->plugin_url . 'libraries/nucleo_icons/nucleo_icons.css', array(), $this->version); | |
| 256 | + //wp_enqueue_style('nucleo_icons'); | |
| 215 | 257 | } |
| 216 | 258 | |
| 217 | 259 | public function meta_boxes($post_type, $post) |
| 218 | 260 | { |
| @@ -245,8 +287,13 @@ | ||
| 245 | 287 | { |
| 246 | 288 | return trailingslashit(plugin_dir_url(MBSOCIAL_ROOT_FILE)); |
| 247 | 289 | } |
| 248 | 290 | |
| 291 | + public function get_page_url() | |
| 292 | + { | |
| 293 | + return $this->url; | |
| 294 | + } | |
| 295 | + | |
| 249 | 296 | public function get_version() |
| 250 | 297 | { |
| 251 | 298 | return MBSOCIAL_VERSION_NUM; |
| 252 | 299 | } |
| @@ -255,8 +302,22 @@ | ||
| 255 | 302 | { |
| 256 | 303 | if (Install::getIssue() == 'mb-wrong-version') |
| 257 | 304 | include_once($this->plugin_path . 'admin/update_mb.php'); |
| 258 | 305 | else |
| 306 | + { | |
| 307 | + $this->url = admin_url('?page=maxbuttons-social'); | |
| 259 | 308 | include_once($this->plugin_path . 'admin/page_editor.php'); |
| 309 | + } | |
| 260 | 310 | } |
| 311 | + | |
| 312 | + public function load_settings_page() | |
| 313 | + { | |
| 314 | + if (Install::getIssue() == 'mb-wrong-version') | |
| 315 | + include_once($this->plugin_path . 'admin/update_mb.php'); | |
| 316 | + else | |
| 317 | + { | |
| 318 | + $this->url = admin_url('?page=maxbuttons-social-settings'); | |
| 319 | + include_once($this->plugin_path . 'admin/page_settings.php'); | |
| 320 | + } | |
| 321 | + } | |
| 261 | 322 | |
| 262 | 323 | } |