PluginProbe
Snippet Shortcodes / 3.0.2
Snippet Shortcodes v3.0.2
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
← All changes | includes/hooks.php +44 -3 2.03.0.2 View file →
@@ -6,12 +6,12 @@
6 6 * Build admin menu
7 7 */
8 8 function sh_cd_build_admin_menu() {
9 9
10 - add_menu_page( SH_CD_PLUGIN_NAME, SH_CD_PLUGIN_NAME, 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_user_defined_page', 'dashicons-editor-kitchensink' );
10 + add_menu_page( SH_CD_PLUGIN_NAME, SH_CD_PLUGIN_NAME, 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_pages_your_shortcodes', 'dashicons-editor-kitchensink' );
11 11
12 12 // Hide duplicated sub menu (wee hack!)
13 - add_submenu_page( 'sh-cd-shortcode-variables-main-menu', '', '', 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_user_defined_page');
13 + add_submenu_page( 'sh-cd-shortcode-variables-main-menu', '', '', 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_pages_your_shortcodes');
14 14
15 15 // Add sub menus
16 16 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Your Shortcodes', SH_CD_SLUG ), __('Your shortcodes'), 'manage_options', 'sh-cd-shortcode-variables-your-shortcodes', 'sh_cd_pages_your_shortcodes');
17 17 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Premade Shortcodes', SH_CD_SLUG ), __('Premade shortcodes'), 'manage_options', 'sh-cd-shortcode-variables-sub-premade', 'sh_cd_premade_shortcodes_page');
@@ -40,9 +40,15 @@
40 40 */
41 41 function sh_cd_upgrade() {
42 42
43 43 if ( true === update_option( 'sh-cd-version-number', SH_CD_PLUGIN_VERSION ) ) {
44 +
44 45 sh_cd_create_database_table();
46 +
47 + if ( true === is_multisite() ) {
48 + sh_cd_create_database_table_multisite();
49 + }
50 +
45 51 }
46 52 }
47 53 add_action('admin_init', 'sh_cd_upgrade');
48 54
@@ -71,8 +77,32 @@
71 77 }
72 78 add_action( 'wp_ajax_toggle_status', 'sh_cd_ajax_toggle_status' );
73 79
74 80 /**
81 +Ajax handler for toggling disable status of a shortcode
82 + **/
83 +function sh_cd_ajax_toggle_multisite() {
84 +
85 + if ( false === sh_cd_license_is_premium() ) {
86 + wp_send_json( 'not-premium' );
87 + }
88 +
89 + check_ajax_referer( 'sh-cd-security', 'security' );
90 +
91 + $id = ( false === empty( $_POST['id'] ) ) ? (int) $_POST['id'] : NULL;
92 +
93 + if ( false === empty( $id ) ) {
94 +
95 + $new_multisite = sh_cd_toggle_multisite( $id );
96 +
97 + wp_send_json( [ 'id' => $id, 'multisite' => $new_multisite, 'ok' => 1 ] );
98 + }
99 +
100 + wp_send_json( 'shortcode-not-found' );
101 +}
102 +add_action( 'wp_ajax_toggle_multisite', 'sh_cd_ajax_toggle_multisite' );
103 +
104 +/**
75 105 Ajax handler for saving shortcode inline
76 106 **/
77 107 function sh_cd_ajax_update_shortcode() {
78 108
@@ -93,5 +123,16 @@
93 123 }
94 124
95 125 wp_send_json( 'shortcode-not-found' );
96 126 }
97 -add_action( 'wp_ajax_update_shortcode', 'sh_cd_ajax_update_shortcode' );
127 +add_action( 'wp_ajax_update_shortcode', 'sh_cd_ajax_update_shortcode' );
128 +
129 +/**
130 + * Replace shortcodes within menu titles.
131 + *
132 + * @param $title
133 + * @return mixed
134 + */
135 +function sh_cd_menu_replace_shortcodes( $title ) {
136 + return do_shortcode( $title );
137 +}
138 +add_filter('nav_menu_item_title', 'sh_cd_menu_replace_shortcodes', 10, 1);