author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 16 | a86126ab1dd4 |
child 21 | 48c4eec2b7e6 |
permissions | -rwxr-xr-x |
5 | 1 |
<?php |
19 | 2 |
/** |
3 |
* @package BWS Menu |
|
4 |
* @version 2.4.2 |
|
5 |
* Main functions |
|
6 |
*/ |
|
5 | 7 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
/** |
19 | 9 |
* General functions for BestWebSoft plugins |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
*/ |
19 | 11 |
require dirname( __FILE__ ) . '/deprecated.php'; |
12 |
require_once dirname( __FILE__ ) . '/deactivation-form.php'; |
|
13 |
||
14 |
||
15 |
if ( ! function_exists( 'bws_get_mofile' ) ) { |
|
16 |
/** |
|
17 |
* Function to add 'bestwebsoft' slug for BWS_Menu MO file if BWS_Menu loaded from theme. |
|
18 |
* |
|
19 |
* @since 1.9.7 |
|
20 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
function bws_get_mofile( $mofile, $domain ) { |
19 | 22 |
if ( 'bestwebsoft' === $domain ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
$locale = get_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
return str_replace( $locale, "bestwebsoft-{$locale}", $mofile ); |
5 | 25 |
} |
26 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
return $mofile; |
5 | 28 |
} |
29 |
} |
|
30 |
||
19 | 31 |
/** |
32 |
* Internationalization, first(!) |
|
33 |
* |
|
34 |
* @since 1.9.7 |
|
35 |
*/ |
|
36 |
if ( isset( $bws_menu_source ) && 'themes' === $bws_menu_source ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
add_filter( 'load_textdomain_mofile', 'bws_get_mofile', 10, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
load_theme_textdomain( 'bestwebsoft', get_stylesheet_directory() . '/inc/bws_menu/languages' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
remove_filter( 'load_textdomain_mofile', 'bws_get_mofile' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
load_plugin_textdomain( 'bestwebsoft', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
* Function to getting url to current BWS_Menu. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
* @since 1.9.7 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
*/ |
19 | 49 |
if ( ! function_exists( 'bws_menu_url' ) ) { |
50 |
if ( ! isset( $bws_menu_source ) || 'plugins' === $bws_menu_source ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
function bws_menu_url( $path = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
return plugins_url( $path, __FILE__ ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
function bws_menu_url( $path = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
$bws_menu_current_dir = str_replace( '\\', '/', dirname( __FILE__ ) ); |
19 | 57 |
$bws_menu_abspath = str_replace( '\\', '/', ABSPATH ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
$bws_menu_current_url = site_url( str_replace( $bws_menu_abspath, '', $bws_menu_current_dir ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
return sprintf( '%s/%s', $bws_menu_current_url, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
} |
5 | 64 |
|
65 |
/** |
|
19 | 66 |
* Function check if plugin is compatible with current WP version |
67 |
* |
|
68 |
* @return void |
|
69 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
if ( ! function_exists( 'bws_wp_min_version_check' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
function bws_wp_min_version_check( $plugin_basename, $plugin_info, $require_wp, $min_wp = false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
global $wp_version, $bws_versions_notice_array; |
19 | 73 |
if ( false === $min_wp ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
$min_wp = $require_wp; |
19 | 75 |
} |
76 |
if ( version_compare( $wp_version, $min_wp, '<' ) ) { |
|
77 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
5 | 78 |
if ( is_plugin_active( $plugin_basename ) ) { |
79 |
deactivate_plugins( $plugin_basename ); |
|
80 |
$admin_url = ( function_exists( 'get_admin_url' ) ) ? get_admin_url( null, 'plugins.php' ) : esc_url( '/wp-admin/plugins.php' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
wp_die( |
5 | 82 |
sprintf( |
83 |
"<strong>%s</strong> %s <strong>WordPress %s</strong> %s <br /><br />%s <a href='%s'>%s</a>.", |
|
19 | 84 |
esc_html( $plugin_info['Name'] ), |
85 |
esc_html__( 'requires', 'bestwebsoft' ), |
|
86 |
esc_html( $require_wp ), |
|
87 |
esc_html__( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'bestwebsoft' ), |
|
88 |
esc_html__( 'Back to the WordPress', 'bestwebsoft' ), |
|
89 |
esc_url( $admin_url ), |
|
90 |
esc_html__( 'Plugins page', 'bestwebsoft' ) |
|
5 | 91 |
) |
92 |
); |
|
93 |
} |
|
19 | 94 |
} elseif ( version_compare( $wp_version, $require_wp, '<' ) ) { |
95 |
$bws_versions_notice_array[] = array( |
|
96 |
'name' => $plugin_info['Name'], |
|
97 |
'version' => $require_wp, |
|
98 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
|
19 | 103 |
/** |
104 |
* Function display review block |
|
105 |
* |
|
106 |
* @echo string |
|
107 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
if ( ! function_exists( 'bws_plugin_reviews_block' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
<div class="bws-plugin-reviews"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
<div class="bws-plugin-reviews-rate"> |
19 | 112 |
<?php esc_html_e( 'Like the plugin?', 'bestwebsoft' ); ?> |
113 |
<a href="https://wordpress.org/support/view/plugin-reviews/<?php echo esc_attr( $plugin_slug ); ?>?filter=5" target="_blank" title="<?php printf( esc_html__( '%s reviews', 'bestwebsoft' ), esc_html( sanitize_text_field( $plugin_name ) ) ); ?>"> |
|
114 |
<?php esc_html_e( 'Rate it', 'bestwebsoft' ); ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
<span class="dashicons dashicons-star-filled"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
<span class="dashicons dashicons-star-filled"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
<span class="dashicons dashicons-star-filled"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
<span class="dashicons dashicons-star-filled"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
<span class="dashicons dashicons-star-filled"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
</a> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
<div class="bws-plugin-reviews-support"> |
19 | 123 |
<?php esc_html_e( 'Need help?', 'bestwebsoft' ); ?> |
124 |
<a href="https://support.bestwebsoft.com"><?php esc_html_e( 'Visit Help Center', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
<div class="bws-plugin-reviews-donate"> |
19 | 127 |
<?php esc_html_e( 'Want to support the plugin?', 'bestwebsoft' ); ?> |
128 |
<a href="https://bestwebsoft.com/donate/"><?php esc_html_e( 'Donate', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
</div> |
19 | 131 |
<?php |
132 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
|
19 | 135 |
/** |
136 |
* Function display license notification |
|
137 |
* |
|
138 |
* @echo string |
|
139 |
*/ |
|
140 |
if ( ! function_exists( 'bws_plugin_update_row' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
function bws_plugin_update_row( $plugin_key, $link_slug = false, $free_plugin_name = false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
global $bstwbsftwppdtplgns_options, $wp_version; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $plugin_key ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
$explode_plugin_key = explode( '/', $plugin_key ); |
19 | 146 |
$class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
147 |
$style = ( $wp_version < 4.6 ) ? ' style="background-color: #FFEBE8;border-color: #CC0000;"' : ''; |
|
148 |
$div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
149 |
echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
<td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
19 | 151 |
<div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>'; |
152 |
if ( $wp_version >= 4.6 ) { |
|
153 |
echo '<p>'; |
|
154 |
} |
|
155 |
echo '<strong>' . esc_html__( 'WARNING: Illegal use notification', 'bestwebsoft' ) . '.</strong> ' . esc_html__( 'You can use one license of the Pro plugin for one domain only. Please check and edit your license or domain if necessary using your personal Client Area. We strongly recommend you to solve the problem within 24 hours, otherwise the Pro plugin will be deactivated.', 'bestwebsoft' ) . ' <a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/articles/204240089">' . esc_html__( 'Learn More', 'bestwebsoft' ) . '</a>'; |
|
156 |
if ( $wp_version >= 4.6 ) { |
|
157 |
echo '</p>'; |
|
158 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
echo '</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
</tr>'; |
19 | 162 |
} elseif ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( gmdate( 'm/d/Y' ) ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
$explode_plugin_key = explode( '/', $plugin_key ); |
19 | 164 |
$class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
165 |
$style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; |
|
166 |
$div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
167 |
echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
<td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
19 | 169 |
<div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>'; |
170 |
if ( $wp_version >= 4.6 ) { |
|
171 |
echo '<p>'; |
|
172 |
} |
|
173 |
if ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) && false !== $link_slug ) { |
|
174 |
echo esc_html__( 'Notice: Your Pro Trial license has expired. To continue using the plugin, you should buy a Pro license', 'bestwebsoft' ) . ' - <a href="https://bestwebsoft.com/products/wordpress/plugins/' . esc_attr( $link_slug ) . '/">https://bestwebsoft.com/products/wordpress/plugins/' . esc_attr( $link_slug ) . '/</a>'; |
|
175 |
} else { |
|
176 |
echo esc_html__( 'Your license has expired. To continue getting top-priority support and plugin updates, you should extend it.', 'bestwebsoft' ) . ' <a target="_new" href="https://support.bestwebsoft.com/entries/53487136">' . esc_html__( 'Learn more', 'bestwebsoft' ) . '</a>'; |
|
177 |
} |
|
178 |
if ( $wp_version >= 4.6 ) { |
|
179 |
echo '</p>'; |
|
180 |
} |
|
181 |
echo '</div> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
</tr>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
} elseif ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
$explode_plugin_key = explode( '/', $plugin_key ); |
19 | 186 |
$class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
187 |
$style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; |
|
188 |
$div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
189 |
echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
<td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
19 | 191 |
<div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>'; |
192 |
if ( $wp_version >= 4.6 ) { |
|
193 |
echo '<p>'; |
|
194 |
} |
|
195 |
if ( false !== $free_plugin_name ) { |
|
196 |
printf( esc_html__( 'Notice: You are using the Pro Trial license of %s plugin.', 'bestwebsoft' ), esc_html( $free_plugin_name ) ); |
|
197 |
} else { |
|
198 |
esc_html_e( 'Notice: You are using the Pro Trial license of plugin.', 'bestwebsoft' ); |
|
199 |
} |
|
200 |
if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) ) { |
|
201 |
echo ' ' . esc_html__( 'The Pro Trial license will expire on', 'bestwebsoft' ) . ' ' . esc_html( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) . '.'; |
|
202 |
} |
|
203 |
if ( $wp_version >= 4.6 ) { |
|
204 |
echo '</p>'; |
|
205 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
echo '</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
</tr>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
|
19 | 213 |
/** |
214 |
* Function display admin notices |
|
215 |
* |
|
216 |
* @echo string |
|
217 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
if ( ! function_exists( 'bws_admin_notices' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
function bws_admin_notices() { |
16 | 220 |
global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options, $bws_plugin_banner_go_pro, $bstwbsftwppdtplgns_banner_array, $bws_plugin_banner_timeout; |
221 |
||
222 |
/* bws_plugin_banner_go_pro */ |
|
223 |
if ( ! empty( $bws_plugin_banner_go_pro ) ) { |
|
224 |
/* get $bws_plugins */ |
|
19 | 225 |
require dirname( __FILE__ ) . '/product_list.php'; |
226 |
||
16 | 227 |
foreach ( $bstwbsftwppdtplgns_banner_array as $value ) { |
228 |
if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) { |
|
229 |
||
230 |
if ( isset( $bws_plugins[ $value[1] ]['pro_version'] ) && is_plugin_active( $bws_plugins[ $value[1] ]['pro_version'] ) ) { |
|
231 |
continue; |
|
232 |
} |
|
233 |
||
19 | 234 |
$single_banner_value = $bws_plugin_banner_go_pro[ $value[0] ]; |
235 |
?> |
|
16 | 236 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
19 | 237 |
<div class="<?php echo esc_attr( $single_banner_value['prefix'] ); ?>_message bws_banner_on_plugin_page bws_go_pro_banner" style="display: none;"> |
238 |
<button class="<?php echo esc_attr( $single_banner_value['prefix'] ); ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
16 | 239 |
<div class="icon"> |
240 |
<img title="" src="<?php echo esc_attr( $single_banner_value['banner_url'] ); ?>" alt="" /> |
|
241 |
</div> |
|
242 |
<div class="text"> |
|
19 | 243 |
<?php esc_html_e( 'It’s time to upgrade your', 'bestwebsoft' ); ?> <strong><?php echo esc_html( $single_banner_value['plugin_info']['Name'] ); ?> plugin</strong> <?php esc_html_e( 'to', 'bestwebsoft' ); ?> <strong>Pro</strong> <?php esc_html_e( 'version!', 'bestwebsoft' ); ?><br /> |
244 |
<span><?php esc_html_e( 'Extend standard plugin functionality with new great options.', 'bestwebsoft' ); ?></span> |
|
16 | 245 |
</div> |
246 |
<div class="button_div"> |
|
19 | 247 |
<a class="button" target="_blank" href="<?php echo esc_url( $single_banner_value['bws_link'] ); ?>"><?php esc_html_e( 'Learn More', 'bestwebsoft' ); ?></a> |
16 | 248 |
</div> |
249 |
</div> |
|
250 |
</div> |
|
19 | 251 |
<?php |
252 |
break; |
|
16 | 253 |
} |
254 |
} |
|
255 |
} |
|
256 |
||
257 |
/* $bws_plugin_banner_timeout */ |
|
258 |
if ( ! empty( $bws_plugin_banner_timeout ) ) { |
|
19 | 259 |
foreach ( $bws_plugin_banner_timeout as $banner_value ) { |
260 |
?> |
|
16 | 261 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
19 | 262 |
<div class="<?php echo esc_attr( $banner_value['prefix'] ); ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;"> |
263 |
<button class="<?php echo esc_attr( $banner_value['prefix'] ); ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
16 | 264 |
<div class="icon"> |
19 | 265 |
<img title="" src="<?php echo esc_url( $banner_value['banner_url'] ); ?>" alt="" /> |
16 | 266 |
</div> |
19 | 267 |
<div class="text"><?php printf( esc_html__( "Your license key for %1\$s expires on %2\$s and you won't be granted TOP-PRIORITY SUPPORT or UPDATES.", 'bestwebsoft' ), '<strong>' . esc_html__( $banner_value['plugin_name'] ) . '</strong>', esc_html__( $bstwbsftwppdtplgns_options['time_out'][ $banner_value['plugin_key'] ] ) ); ?> <a target="_new" href="https://support.bestwebsoft.com/entries/53487136"><?php esc_html_e( 'Learn more', 'bestwebsoft' ); ?></a></div> |
16 | 268 |
</div> |
269 |
</div> |
|
19 | 270 |
<?php |
271 |
} |
|
16 | 272 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
/* versions notice */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
if ( ! empty( $bws_versions_notice_array ) ) { |
19 | 276 |
foreach ( $bws_versions_notice_array as $key => $value ) { |
277 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
<div class="update-nag"> |
19 | 279 |
<?php |
280 |
printf( |
|
281 |
'<strong>%s</strong> %s <strong>WordPress %s</strong> %s', |
|
282 |
esc_html__( $value['name'] ), |
|
283 |
esc_html__( 'requires', 'bestwebsoft' ), |
|
284 |
esc_html__( $value['version'] ), |
|
285 |
esc_html__( 'or higher! We do not guarantee that our plugin will work correctly. Please upgrade to WordPress latest version.', 'bestwebsoft' ) |
|
286 |
); |
|
287 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
</div> |
19 | 289 |
<?php |
290 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
/* banner_to_settings notice */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
if ( ! empty( $bws_plugin_banner_to_settings ) ) { |
19 | 295 |
if ( 1 === count( $bws_plugin_banner_to_settings ) ) { |
296 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
<div class="bws_banner_on_plugin_page bws_banner_to_settings"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
<div class="icon"> |
19 | 300 |
<img title="" src="<?php echo esc_url( $bws_plugin_banner_to_settings[0]['banner_url'] ); ?>" alt="" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
<div class="text"> |
19 | 303 |
<strong><?php printf( esc_html__( 'Thank you for installing %s plugin!', 'bestwebsoft' ), esc_html( $bws_plugin_banner_to_settings[0]['plugin_info']['Name'] ) ); ?></strong> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
<br /> |
19 | 305 |
<?php esc_html_e( "Let's get started", 'bestwebsoft' ); ?>: |
306 |
<a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['settings_url'] ) ); ?>"><?php esc_html_e( 'Settings', 'bestwebsoft' ); ?></a> |
|
307 |
<?php if ( false !== $bws_plugin_banner_to_settings[0]['post_type_url'] ) { ?> |
|
308 |
<?php esc_html_e( 'or', 'bestwebsoft' ); ?> |
|
309 |
<a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['post_type_url'] ) ); ?>"><?php esc_html_e( 'Add New', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
<form action="" method="post"> |
19 | 313 |
<button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
314 |
<input type="hidden" name="bws_hide_settings_notice_<?php echo esc_html( $bws_plugin_banner_to_settings[0]['plugin_options_name'] ); ?>" value="hide" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
<?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
<?php } else { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
<div class="bws_banner_on_plugin_page bws_banner_to_settings_joint"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
<form action="" method="post"> |
19 | 323 |
<button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
<div class="bws-text"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
<div class="icon"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
<span class="dashicons dashicons-admin-plugins"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
</div> |
19 | 328 |
<strong><?php esc_html_e( 'Thank you for installing plugins by BestWebSoft!', 'bestwebsoft' ); ?></strong> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
<div class="hide-if-no-js bws-more-links"> |
19 | 330 |
<a href="#" class="bws-more"><?php esc_html_e( 'More Details', 'bestwebsoft' ); ?></a> |
331 |
<a href="#" class="bws-less hidden"><?php esc_html_e( 'Less Details', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
<?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
<div class="clear"></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
<div class="bws-details hide-if-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
<?php foreach ( $bws_plugin_banner_to_settings as $value ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
<div> |
19 | 339 |
<strong><?php echo esc_html( str_replace( ' by BestWebSoft', '', $value['plugin_info']['Name'] ) ); ?></strong> <a href="<?php echo esc_url( self_admin_url( $value['settings_url'] ) ); ?>"><?php esc_html_e( 'Settings', 'bestwebsoft' ); ?></a> |
340 |
<?php if ( false !== $value['post_type_url'] ) { ?> |
|
341 |
 | <a target="_blank" href="<?php echo esc_url( self_admin_url( $value['post_type_url'] ) ); ?>"><?php esc_html_e( 'Add New', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
<?php } ?> |
19 | 343 |
<input type="hidden" name="bws_hide_settings_notice_<?php echo esc_html( $value['plugin_options_name'] ); ?>" value="hide" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
</div> |
19 | 350 |
<?php |
351 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
/** |
19 | 355 |
* Show notices about deprecated_function |
356 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
* @since 1.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
*/ |
19 | 359 |
if ( ! empty( $bstwbsftwppdtplgns_options['deprecated_function'] ) ) { |
360 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
<div class="update-nag"> |
19 | 362 |
<strong><?php esc_html_e( 'Deprecated function(-s) is used on the site here:', 'bestwebsoft' ); ?></strong> |
363 |
<?php |
|
364 |
$i = 1; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
foreach ( $bstwbsftwppdtplgns_options['deprecated_function'] as $function_name => $attr ) { |
19 | 366 |
if ( 1 !== $i ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
echo ' ,'; |
19 | 368 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
if ( ! empty( $attr['product-name'] ) ) { |
19 | 370 |
echo esc_html( $attr['product-name'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
} elseif ( ! empty( $attr['file'] ) ) { |
19 | 372 |
echo esc_url( $attr['file'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
unset( $bstwbsftwppdtplgns_options['deprecated_function'][ $function_name ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
$i++; |
19 | 376 |
} |
377 |
?> |
|
378 |
. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
<br/> |
19 | 380 |
<?php esc_html_e( 'This function(-s) will be removed over time. Please update the product(-s).', 'bestwebsoft' ); ?> |
12 | 381 |
</div> |
19 | 382 |
<?php |
383 |
if ( is_multisite() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 385 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 387 |
} |
5 | 388 |
} |
389 |
} |
|
390 |
} |
|
391 |
||
19 | 392 |
/** |
393 |
* Function display banner |
|
394 |
* |
|
395 |
* @return array |
|
396 |
*/ |
|
16 | 397 |
if ( ! function_exists( 'bws_plugin_banner_go_pro' ) ) { |
398 |
function bws_plugin_banner_go_pro( $plugin_options, $plugin_info, $this_banner_prefix, $bws_link_slug, $link_key, $link_pn, $banner_url_or_slug ) { |
|
399 |
global $bws_plugin_banner_go_pro, $wp_version, $bstwbsftwppdtplgns_banner_array; |
|
400 |
||
19 | 401 |
if ( ! isset( $plugin_options['first_install'] ) || strtotime( '-1 week' ) < $plugin_options['first_install'] ) { |
16 | 402 |
return; |
19 | 403 |
} |
16 | 404 |
|
19 | 405 |
$bws_link = esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $bws_link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info['Version'] . '&wp_v=' . $wp_version ); |
16 | 406 |
|
19 | 407 |
if ( false === strrpos( $banner_url_or_slug, '/' ) ) { |
16 | 408 |
$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; |
409 |
} |
|
410 |
||
411 |
$bws_plugin_banner_go_pro[ $this_banner_prefix . '_hide_banner_on_plugin_page' ] = array( |
|
19 | 412 |
'plugin_info' => $plugin_info, |
413 |
'prefix' => $this_banner_prefix, |
|
414 |
'bws_link' => $bws_link, |
|
415 |
'banner_url' => $banner_url_or_slug, |
|
16 | 416 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
|
5 | 418 |
if ( empty( $bstwbsftwppdtplgns_banner_array ) ) { |
19 | 419 |
if ( ! function_exists( 'bws_get_banner_array' ) ) { |
420 |
require_once dirname( __FILE__ ) . '/bws_menu.php'; |
|
421 |
} |
|
5 | 422 |
bws_get_banner_array(); |
423 |
} |
|
424 |
} |
|
425 |
} |
|
426 |
||
19 | 427 |
/** |
428 |
* Function update banner params |
|
429 |
* |
|
430 |
* @return global array |
|
431 |
*/ |
|
16 | 432 |
if ( ! function_exists( 'bws_add_plugin_banner_timeout' ) ) { |
433 |
function bws_add_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug ) { |
|
434 |
global $bws_plugin_banner_timeout; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
|
19 | 436 |
if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( gmdate( 'm/d/Y' ) . '+1 month' ) ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) > strtotime( gmdate( 'm/d/Y' ) ) ) ) { |
16 | 437 |
|
19 | 438 |
if ( false === strrpos( $banner_url_or_slug, '/' ) ) { |
16 | 439 |
$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
|
16 | 442 |
$bws_plugin_banner_timeout[] = array( |
19 | 443 |
'plugin_key' => $plugin_key, |
444 |
'prefix' => $plugin_prefix, |
|
445 |
'plugin_name' => $plugin_name, |
|
446 |
'banner_url' => $banner_url_or_slug, |
|
16 | 447 |
); |
448 |
} |
|
5 | 449 |
} |
450 |
} |
|
451 |
||
19 | 452 |
/** |
453 |
* Function settings for banner |
|
454 |
* |
|
455 |
* @return global array |
|
456 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
global $bws_plugin_banner_to_settings; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
$is_network_admin = is_network_admin(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
$plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
|
19 | 465 |
if ( isset( $plugin_options['display_settings_notice'] ) && 0 === $plugin_options['display_settings_notice'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
|
19 | 469 |
if ( isset( $_POST[ 'bws_hide_settings_notice_' . $plugin_options_name ] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ) ) { |
470 |
$plugin_options['display_settings_notice'] = 0; |
|
471 |
if ( $is_network_admin ) { |
|
472 |
update_site_option( $plugin_options_name, $plugin_options ); |
|
473 |
} else { |
|
474 |
update_option( $plugin_options_name, $plugin_options ); |
|
475 |
} |
|
476 |
return; |
|
477 |
} |
|
478 |
||
479 |
if ( false === strrpos( $banner_url_or_slug, '/' ) ) { |
|
16 | 480 |
$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
$bws_plugin_banner_to_settings[] = array( |
19 | 484 |
'plugin_info' => $plugin_info, |
485 |
'plugin_options_name' => $plugin_options_name, |
|
486 |
'banner_url' => $banner_url_or_slug, |
|
487 |
'settings_url' => $settings_url, |
|
488 |
'post_type_url' => $post_type_url, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
); |
5 | 490 |
} |
491 |
} |
|
492 |
||
19 | 493 |
/** |
494 |
* Function display for feature banner |
|
495 |
* |
|
496 |
* @echo string |
|
497 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
if ( ! function_exists( 'bws_plugin_suggest_feature_banner' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
499 |
function bws_plugin_suggest_feature_banner( $plugin_info, $plugin_options_name, $banner_url_or_slug ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
$is_network_admin = is_network_admin(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
501 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
$plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
|
19 | 504 |
if ( isset( $plugin_options['display_suggest_feature_banner'] ) && 0 === $plugin_options['display_suggest_feature_banner'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
return; |
19 | 506 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
if ( ! isset( $plugin_options['first_install'] ) ) { |
19 | 509 |
$plugin_options['first_install'] = strtotime( 'now' ); |
510 |
$update_option = $return = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
} elseif ( strtotime( '-2 week' ) < $plugin_options['first_install'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
$return = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
if ( ! isset( $plugin_options['go_settings_counter'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
$plugin_options['go_settings_counter'] = 1; |
19 | 517 |
$update_option = $return = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
} elseif ( 20 > $plugin_options['go_settings_counter'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
$plugin_options['go_settings_counter'] = $plugin_options['go_settings_counter'] + 1; |
19 | 520 |
$update_option = $return = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
if ( isset( $update_option ) ) { |
19 | 524 |
if ( $is_network_admin ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
525 |
update_site_option( $plugin_options_name, $plugin_options ); |
19 | 526 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
update_option( $plugin_options_name, $plugin_options ); |
19 | 528 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
530 |
|
19 | 531 |
if ( isset( $return ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
|
19 | 535 |
if ( isset( $_POST[ 'bws_hide_suggest_feature_banner_' . $plugin_options_name ] ) && check_admin_referer( $plugin_info['Name'], 'bws_settings_nonce_name' ) ) { |
536 |
$plugin_options['display_suggest_feature_banner'] = 0; |
|
537 |
if ( $is_network_admin ) { |
|
538 |
update_site_option( $plugin_options_name, $plugin_options ); |
|
539 |
} else { |
|
540 |
update_option( $plugin_options_name, $plugin_options ); |
|
541 |
} |
|
542 |
return; |
|
543 |
} |
|
544 |
||
545 |
if ( false === strrpos( $banner_url_or_slug, '/' ) ) { |
|
16 | 546 |
$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; |
19 | 547 |
} |
548 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
<div class="bws_banner_on_plugin_page bws_suggest_feature_banner"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
<div class="icon"> |
19 | 552 |
<img title="" src="<?php echo esc_url( $banner_url_or_slug ); ?>" alt="" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
<div class="text"> |
19 | 555 |
<strong><?php printf( esc_html__( 'Thank you for choosing %s plugin!', 'bestwebsoft' ), esc_html( $plugin_info['Name'] ) ); ?></strong><br /> |
556 |
<?php esc_html_e( "If you have a feature, suggestion or idea you'd like to see in the plugin, we'd love to hear about it!", 'bestwebsoft' ); ?> |
|
557 |
<a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/requests/new"><?php esc_html_e( 'Suggest a Feature', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
559 |
<form action="" method="post"> |
19 | 560 |
<button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
561 |
<input type="hidden" name="bws_hide_suggest_feature_banner_<?php echo esc_html( $plugin_options_name ); ?>" value="hide" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
<?php wp_nonce_field( $plugin_info['Name'], 'bws_settings_nonce_name' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
</div> |
19 | 566 |
<?php |
567 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
|
19 | 570 |
/** |
571 |
* Function display affiliate postbox |
|
572 |
* |
|
573 |
* @echo string |
|
574 |
*/ |
|
575 |
if ( ! function_exists( 'bws_affiliate_postbox' ) ) { |
|
576 |
function bws_affiliate_postbox() { |
|
577 |
||
578 |
$dismissed = get_user_meta( get_current_user_id(), '_bws_affiliate_postbox_dismissed', true ); |
|
579 |
||
580 |
if ( ! empty( $dismissed ) && strtotime( '-3 month' ) < $dismissed ) { |
|
581 |
return; |
|
582 |
} |
|
583 |
||
584 |
if ( isset( $_POST['bws_hide_affiliate_banner'] ) && check_admin_referer( 'bws_affiliate_postbox', 'bws_settings_nonce_name' ) ) { |
|
585 |
update_user_meta( get_current_user_id(), '_bws_affiliate_postbox_dismissed', strtotime( 'now' ) ); |
|
586 |
return; |
|
587 |
} |
|
588 |
||
589 |
$bws_link = esc_url( 'https://bestwebsoft.com/affiliate/?utm_source=plugin&utm_medium=settings&utm_campaign=affiliate_program' ); |
|
590 |
?> |
|
591 |
<div id="bws-affiliate-postbox" class="postbox"> |
|
592 |
<form action="" method="post"> |
|
593 |
<button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
594 |
<input type="hidden" name="bws_hide_affiliate_banner" value="hide" /> |
|
595 |
<?php wp_nonce_field( 'bws_affiliate_postbox', 'bws_settings_nonce_name' ); ?> |
|
596 |
</form> |
|
597 |
<p>BESTWEBSOFT</p> |
|
598 |
<h3><?php esc_html_e( 'Affiliate Program', 'bestwebsoft' ); ?></h3> |
|
599 |
<div class="bws-affiliate-get"><?php printf( esc_html__( 'Get %s', 'bestwebsoft' ), '20%' ); ?></div> |
|
600 |
<div><?php esc_html_e( 'from each BestWebSoft plugin and theme sale you refer', 'bestwebsoft' ); ?></div> |
|
601 |
<div class="bws-row"> |
|
602 |
<div class="bws-cell"> |
|
603 |
<img src="<?php echo esc_url( bws_menu_url( 'images/join-icon.svg' ) ); ?>" alt="" /> |
|
604 |
<div><?php esc_html_e( 'Join affiliate program', 'bestwebsoft' ); ?></div> |
|
605 |
</div> |
|
606 |
<div class="bws-cell"> |
|
607 |
<img src="<?php echo esc_url( bws_menu_url( 'images/promote-icon.svg' ) ); ?>" alt="" /> |
|
608 |
<div><?php esc_html_e( 'Promote and sell products', 'bestwebsoft' ); ?></div> |
|
609 |
</div> |
|
610 |
<div class="bws-cell"> |
|
611 |
<img src="<?php echo esc_url( bws_menu_url( 'images/earn-icon.svg' ) ); ?>" alt="" /> |
|
612 |
<div><?php esc_html_e( 'Get commission!', 'bestwebsoft' ); ?></div> |
|
613 |
</div> |
|
614 |
</div> |
|
615 |
<div class="clear"></div> |
|
616 |
<p> |
|
617 |
<a class="button" href="<?php echo esc_url( $bws_link ); ?>" target="_blank"><?php esc_html_e( 'Start Now', 'bestwebsoft' ); ?></a> |
|
618 |
</p> |
|
619 |
</div> |
|
620 |
<?php |
|
621 |
} |
|
622 |
} |
|
623 |
||
624 |
/** |
|
625 |
* Function display settings notice |
|
626 |
* |
|
627 |
* @echo string |
|
628 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
if ( ! function_exists( 'bws_show_settings_notice' ) ) { |
19 | 630 |
function bws_show_settings_notice() { |
631 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
<div id="bws_save_settings_notice" class="updated fade below-h2" style="display:none;"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
<p> |
19 | 634 |
<strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?></strong>: <?php esc_html_e( "The plugin's settings have been changed.", 'bestwebsoft' ); ?> |
635 |
<a class="bws_save_anchor" href="#bws-submit-button"><?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
</div> |
19 | 638 |
<?php |
639 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
|
19 | 642 |
/** |
643 |
* Function for hide premium options |
|
644 |
* |
|
645 |
* @echo string |
|
646 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
if ( ! function_exists( 'bws_hide_premium_options' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
function bws_hide_premium_options( $options ) { |
19 | 649 |
if ( ! isset( $options['hide_premium_options'] ) || ! is_array( $options['hide_premium_options'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
$options['hide_premium_options'] = array(); |
19 | 651 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
$options['hide_premium_options'][] = get_current_user_id(); |
5 | 654 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
return array( |
19 | 656 |
'message' => esc_html__( 'You can always look at premium options by checking the "Pro Options" in the "Misc" tab.', 'bestwebsoft' ), |
657 |
'options' => $options, |
|
658 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
660 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
|
19 | 662 |
/** |
663 |
* Function for check checkbox for hide premium options |
|
664 |
* |
|
665 |
* @return bool |
|
666 |
*/ |
|
667 |
if ( ! function_exists( 'bws_hide_premium_options_check' ) ) { |
|
668 |
function bws_hide_premium_options_check( $options ) { |
|
669 |
if ( ! empty( $options['hide_premium_options'] ) && in_array( get_current_user_id(), $options['hide_premium_options'] ) ) { |
|
670 |
return true; |
|
671 |
} else { |
|
672 |
return false; |
|
673 |
} |
|
674 |
} |
|
675 |
} |
|
676 |
||
677 |
/** |
|
678 |
* Function init fir dashboard |
|
679 |
*/ |
|
680 |
if ( ! function_exists( 'bws_plugins_admin_init' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
function bws_plugins_admin_init() { |
19 | 682 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
683 |
if ( isset( $_GET['bws_activate_plugin'] ) && check_admin_referer( 'bws_activate_plugin' . sanitize_text_field( wp_unslash( $_GET['bws_activate_plugin'] ) ) ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
684 |
|
19 | 685 |
$plugin = isset( $_GET['bws_activate_plugin'] ) ? sanitize_text_field( wp_unslash( $_GET['bws_activate_plugin'] ) ) : ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
$result = activate_plugin( $plugin, '', is_network_admin() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
if ( is_wp_error( $result ) ) { |
19 | 688 |
if ( 'unexpected_output' === $result->get_error_code() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
$redirect = self_admin_url( 'admin.php?page=bws_panel&error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . $plugin ); |
19 | 690 |
wp_safe_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
exit(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
} else { |
19 | 693 |
wp_die( esc_html( $result ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
if ( ! is_network_admin() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
$recent = (array) get_option( 'recently_activated' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
unset( $recent[ $plugin ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
update_option( 'recently_activated', $recent ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
$recent = (array) get_site_option( 'recently_activated' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
unset( $recent[ $plugin ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
update_site_option( 'recently_activated', $recent ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
* @deprecated 1.9.8 (15.12.2016) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
*/ |
19 | 709 |
$is_main_page = in_array( $page, array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ); |
710 |
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
|
19 | 712 |
if ( $is_main_page ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
$current_page = 'admin.php?page=' . $page; |
19 | 714 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
$current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page; |
19 | 716 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
/*end deprecated */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
|
19 | 719 |
wp_safe_redirect( self_admin_url( esc_url( $current_page . '&activate=true' ) ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
exit(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
|
19 | 723 |
if ( 'bws_panel' === $page || strpos( $page, '-bws-panel' ) ) { |
724 |
if ( ! session_id() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
@session_start(); |
19 | 726 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
bws_add_editor_buttons(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
|
19 | 733 |
/** |
734 |
* Function add scripts ans syles for dashboard |
|
735 |
*/ |
|
736 |
if ( ! function_exists( 'bws_admin_enqueue_scripts' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
function bws_admin_enqueue_scripts() { |
16 | 738 |
global $wp_scripts, $hook_suffix, |
739 |
$post_type, |
|
740 |
$bws_plugin_banner_go_pro, $bws_plugin_banner_timeout, $bstwbsftwppdtplgns_banner_array, |
|
19 | 741 |
$bws_shortcode_list, |
742 |
$wp_filesystem; |
|
743 |
||
744 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
|
16 | 746 |
$jquery_ui_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1'; |
19 | 747 |
WP_Filesystem(); |
748 |
if ( ! $wp_filesystem->exists( dirname( __FILE__ ) . '/css/jquery-ui-styles/' . $jquery_ui_version . '/' ) ) { |
|
749 |
$jquery_ui_version = '1.12.1'; |
|
750 |
} |
|
751 |
if ( 'et_divi_options' !== $page ) { |
|
752 |
wp_enqueue_style( 'jquery-ui-style', bws_menu_url( 'css/jquery-ui-styles/' . $jquery_ui_version . '/jquery-ui.css', array(), $jquery_ui_version ) ); |
|
753 |
} |
|
754 |
wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ), array(), '2.4.2' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
|
19 | 757 |
if ( in_array( $page, array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ) || strpos( $page, '-bws-panel' ) ) { |
758 |
wp_enqueue_style( 'bws_menu_style', bws_menu_url( 'css/style.css' ), array(), '2.4.2' ); |
|
759 |
wp_enqueue_script( 'bws_menu_script', bws_menu_url( 'js/bws_menu.js' ), array(), '2.4.2', true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
wp_enqueue_script( 'theme-install' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
add_thickbox(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
wp_enqueue_script( 'plugin-install' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
} |
12 | 764 |
|
19 | 765 |
if ( 'plugins.php' === $hook_suffix ) { |
16 | 766 |
if ( ! empty( $bws_plugin_banner_go_pro ) || ! empty( $bws_plugin_banner_timeout ) ) { |
767 |
wp_enqueue_script( 'bws_menu_cookie', bws_menu_url( 'js/c_o_o_k_i_e.js' ) ); |
|
768 |
||
769 |
if ( ! empty( $bws_plugin_banner_go_pro ) ) { |
|
770 |
||
771 |
foreach ( $bstwbsftwppdtplgns_banner_array as $value ) { |
|
772 |
if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) { |
|
773 |
$prefix = $bws_plugin_banner_go_pro[ $value[0] ]['prefix']; |
|
774 |
||
775 |
$script = "(function($) { |
|
776 |
$(document).ready( function() { |
|
777 |
var hide_message = $.cookie( '" . $prefix . "_hide_banner_on_plugin_page' ); |
|
19 | 778 |
if ( hide_message === 'true' ) { |
16 | 779 |
$( '." . $prefix . "_message' ).css( 'display', 'none' ); |
780 |
} else { |
|
781 |
$( '." . $prefix . "_message' ).css( 'display', 'block' ); |
|
782 |
}; |
|
783 |
$( '." . $prefix . "_close_icon' ).click( function() { |
|
784 |
$( '." . $prefix . "_message' ).css( 'display', 'none' ); |
|
785 |
$.cookie( '" . $prefix . "_hide_banner_on_plugin_page', 'true', { expires: 32, secure: true } ); |
|
786 |
}); |
|
787 |
}); |
|
788 |
})(jQuery);"; |
|
789 |
||
790 |
wp_register_script( $prefix . '_hide_banner_on_plugin_page', '' ); |
|
791 |
wp_enqueue_script( $prefix . '_hide_banner_on_plugin_page' ); |
|
792 |
wp_add_inline_script( $prefix . '_hide_banner_on_plugin_page', sprintf( $script ) ); |
|
793 |
break; |
|
794 |
} |
|
795 |
} |
|
796 |
} |
|
797 |
||
798 |
if ( ! empty( $bws_plugin_banner_timeout ) ) { |
|
799 |
$script = '(function($) { |
|
800 |
$(document).ready( function() {'; |
|
801 |
||
802 |
foreach ( $bws_plugin_banner_timeout as $banner_value ) { |
|
803 |
$script .= "var hide_message = $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page' ); |
|
19 | 804 |
if ( hide_message === 'true' ) { |
16 | 805 |
$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' ); |
806 |
} else { |
|
807 |
$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'block' ); |
|
808 |
} |
|
809 |
$( '." . $banner_value['prefix'] . "_close_icon' ).click( function() { |
|
810 |
$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' ); |
|
811 |
$.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page', 'true', { expires: 30, secure: true } ); |
|
812 |
});"; |
|
813 |
} |
|
814 |
||
19 | 815 |
$script .= '}); |
816 |
})(jQuery);'; |
|
16 | 817 |
|
818 |
wp_register_script( 'plugin_banner_timeout_hide', '' ); |
|
819 |
wp_enqueue_script( 'plugin_banner_timeout_hide' ); |
|
820 |
wp_add_inline_script( 'plugin_banner_timeout_hide', sprintf( $script ) ); |
|
821 |
} |
|
822 |
} |
|
823 |
||
824 |
if ( ! defined( 'DOING_AJAX' ) ) { |
|
825 |
wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) ); |
|
826 |
||
827 |
bws_add_deactivation_feedback_dialog_box(); |
|
828 |
} |
|
829 |
} |
|
830 |
||
831 |
if ( ! empty( $bws_shortcode_list ) ) { |
|
832 |
/* TinyMCE Shortcode Plugin */ |
|
833 |
$script = "var bws_shortcode_button = { |
|
19 | 834 |
'label': '" . esc_attr__( 'Add BWS Shortcode', 'bestwebsoft' ) . "', |
835 |
'title': '" . esc_attr__( 'Add BWS Plugins Shortcode', 'bestwebsoft' ) . "', |
|
16 | 836 |
'function_name': ["; |
19 | 837 |
foreach ( $bws_shortcode_list as $value ) { |
838 |
if ( isset( $value['js_function'] ) ) { |
|
839 |
$script .= "'" . $value['js_function'] . "',"; |
|
840 |
} |
|
841 |
} |
|
842 |
$script .= '] |
|
843 |
};'; |
|
16 | 844 |
wp_register_script( 'bws_shortcode_button', '' ); |
845 |
wp_enqueue_script( 'bws_shortcode_button' ); |
|
846 |
wp_add_inline_script( 'bws_shortcode_button', sprintf( $script ) ); |
|
847 |
||
848 |
/* TinyMCE Shortcode Plugin */ |
|
849 |
if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) { |
|
850 |
$tooltip_args = array( |
|
19 | 851 |
'tooltip_id' => 'bws_shortcode_button_tooltip', |
852 |
'css_selector' => '.mce-bws_shortcode_button', |
|
853 |
'actions' => array( |
|
854 |
'click' => false, |
|
855 |
'onload' => true, |
|
16 | 856 |
), |
19 | 857 |
'content' => '<h3>' . esc_html__( 'Add shortcode', 'bestwebsoft' ) . '</h3><p>' . esc_html__( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '</p>', |
858 |
'position' => array( |
|
859 |
'edge' => 'right', |
|
16 | 860 |
), |
19 | 861 |
'set_timeout' => 2000, |
16 | 862 |
); |
863 |
bws_add_tooltip_in_admin( $tooltip_args ); |
|
864 |
} |
|
5 | 865 |
} |
866 |
} |
|
867 |
} |
|
868 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
869 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
* add styles and scripts for Bws_Settings_Tabs |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
872 |
* @since 1.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
function bws_enqueue_settings_scripts() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
wp_enqueue_script( 'jquery-ui-resizable' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
wp_enqueue_script( 'jquery-ui-tabs' ); |
19 | 878 |
wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ), array(), '2.4.2' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
|
19 | 882 |
/** |
883 |
* Function add syles into admin head |
|
884 |
* |
|
885 |
* @since 1.9.8 |
|
886 |
*/ |
|
887 |
if ( ! function_exists( 'bws_plugins_admin_head' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
function bws_plugins_admin_head() { |
19 | 889 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
890 |
||
891 |
if ( $page === 'bws_panel' ) { |
|
892 |
?> |
|
5 | 893 |
<noscript> |
894 |
<style type="text/css"> |
|
895 |
.bws_product_button { |
|
896 |
display: inline-block; |
|
897 |
} |
|
898 |
</style> |
|
899 |
</noscript> |
|
19 | 900 |
<?php |
901 |
} |
|
902 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
|
19 | 905 |
/** |
906 |
* Function add syles into admin footer |
|
907 |
* |
|
908 |
* @since 1.9.8 |
|
909 |
*/ |
|
910 |
if ( ! function_exists( 'bws_plugins_admin_footer' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
function bws_plugins_admin_footer() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
bws_shortcode_media_button_popup(); |
5 | 913 |
} |
914 |
} |
|
915 |
||
19 | 916 |
/** |
917 |
* Function add style and scripts for older version |
|
918 |
* |
|
919 |
* @since 1.9.8 |
|
920 |
*/ |
|
921 |
if ( ! function_exists( 'bws_plugins_include_codemirror' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
function bws_plugins_include_codemirror() { |
16 | 923 |
global $wp_version; |
19 | 924 |
if ( version_compare( $wp_version, '4.9.0', '>=' ) ) { |
16 | 925 |
wp_enqueue_style( 'wp-codemirror' ); |
926 |
wp_enqueue_script( 'wp-codemirror' ); |
|
19 | 927 |
} else { |
928 |
wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ), array(), '2.4.2' ); |
|
929 |
wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ), '2.4.2' ); |
|
930 |
} |
|
16 | 931 |
|
19 | 932 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
933 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
|
5 | 935 |
/** |
936 |
* Tooltip block |
|
937 |
*/ |
|
938 |
if ( ! function_exists( 'bws_add_tooltip_in_admin' ) ) { |
|
939 |
function bws_add_tooltip_in_admin( $tooltip_args = array() ) { |
|
19 | 940 |
new BWS_Admin_Tooltip( $tooltip_args ); |
5 | 941 |
} |
942 |
} |
|
943 |
||
19 | 944 |
/** |
945 |
* Class for Tooltip |
|
946 |
* |
|
947 |
* @since 1.9.8 |
|
948 |
*/ |
|
949 |
if ( ! class_exists( 'BWS_Admin_Tooltip' ) ) { |
|
950 |
class BWS_Admin_Tooltip { |
|
5 | 951 |
private $tooltip_args; |
952 |
||
953 |
public function __construct( $tooltip_args ) { |
|
16 | 954 |
global $bstwbsftwppdtplgns_tooltip_script_add; |
955 |
||
5 | 956 |
/* Default arguments */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
$tooltip_args_default = array( |
19 | 958 |
'tooltip_id' => false, |
959 |
'css_selector' => false, |
|
960 |
'actions' => array( |
|
961 |
'click' => true, |
|
962 |
'onload' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
), |
19 | 964 |
'buttons' => array( |
965 |
'close' => array( |
|
5 | 966 |
'type' => 'dismiss', |
19 | 967 |
'text' => esc_html__( 'Close', 'bestwebsoft' ), |
5 | 968 |
), |
969 |
), |
|
19 | 970 |
'position' => array( |
971 |
'edge' => 'top', |
|
972 |
'align' => 'center', |
|
973 |
'pos-left' => 0, |
|
974 |
'pos-top' => 0, |
|
975 |
'zindex' => 10000, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
), |
19 | 977 |
'set_timeout' => 0, |
5 | 978 |
); |
19 | 979 |
$tooltip_args = array_merge( $tooltip_args_default, $tooltip_args ); |
5 | 980 |
/* Check that our merged array has default values */ |
981 |
foreach ( $tooltip_args_default as $arg_key => $arg_value ) { |
|
982 |
if ( is_array( $arg_value ) ) { |
|
19 | 983 |
foreach ( $arg_value as $key => $value ) { |
5 | 984 |
if ( ! isset( $tooltip_args[ $arg_key ][ $key ] ) ) { |
985 |
$tooltip_args[ $arg_key ][ $key ] = $tooltip_args_default[ $arg_key ][ $key ]; |
|
986 |
} |
|
987 |
} |
|
988 |
} |
|
989 |
} |
|
990 |
/* Check if tooltip is dismissed */ |
|
991 |
if ( true === $tooltip_args['actions']['onload'] ) { |
|
992 |
if ( in_array( $tooltip_args['tooltip_id'], array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ) ) ) { |
|
993 |
$tooltip_args['actions']['onload'] = false; |
|
994 |
} |
|
995 |
} |
|
996 |
/* Check entered data */ |
|
997 |
if ( false === $tooltip_args['tooltip_id'] || false === $tooltip_args['css_selector'] || ( false === $tooltip_args['actions']['click'] && false === $tooltip_args['actions']['onload'] ) ) { |
|
998 |
/* if not enough data to output a tooltip or both actions (click, onload) are false */ |
|
999 |
return; |
|
1000 |
} else { |
|
1001 |
/* check position */ |
|
19 | 1002 |
if ( ! in_array( $tooltip_args['position']['edge'], array( 'left', 'right', 'top', 'bottom' ) ) ) { |
5 | 1003 |
$tooltip_args['position']['edge'] = 'top'; |
1004 |
} |
|
19 | 1005 |
if ( ! in_array( $tooltip_args['position']['align'], array( 'top', 'bottom', 'left', 'right', 'center' ) ) ) { |
5 | 1006 |
$tooltip_args['position']['align'] = 'center'; |
1007 |
} |
|
1008 |
} |
|
1009 |
/* fix position */ |
|
1010 |
switch ( $tooltip_args['position']['edge'] ) { |
|
1011 |
case 'left': |
|
1012 |
case 'right': |
|
1013 |
switch ( $tooltip_args['position']['align'] ) { |
|
1014 |
case 'top': |
|
1015 |
case 'bottom': |
|
1016 |
$tooltip_args['position']['align'] = 'center'; |
|
1017 |
break; |
|
1018 |
} |
|
1019 |
break; |
|
1020 |
case 'top': |
|
1021 |
case 'bottom': |
|
19 | 1022 |
if ( 'left' === $tooltip_args['position']['align'] ) { |
5 | 1023 |
$tooltip_args['position']['pos-left'] -= 65; |
1024 |
} |
|
1025 |
break; |
|
1026 |
} |
|
1027 |
$this->tooltip_args = $tooltip_args; |
|
1028 |
/* add styles and scripts */ |
|
1029 |
wp_enqueue_style( 'wp-pointer' ); |
|
1030 |
wp_enqueue_script( 'wp-pointer' ); |
|
1031 |
/* add script that displays our tooltip */ |
|
1032 |
if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) { |
|
19 | 1033 |
wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ), array(), '2.4.2' ); |
5 | 1034 |
$bstwbsftwppdtplgns_tooltip_script_add = true; |
1035 |
} |
|
16 | 1036 |
$tooltip_args = $this->tooltip_args; |
1037 |
||
19 | 1038 |
$script = '(function($) { |
5 | 1039 |
$(document).ready( function() { |
19 | 1040 |
$.bwsTooltip( ' . wp_json_encode( $tooltip_args ) . ' ); |
5 | 1041 |
}) |
19 | 1042 |
})(jQuery);'; |
16 | 1043 |
wp_register_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], '' ); |
1044 |
wp_enqueue_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'] ); |
|
1045 |
wp_add_inline_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], sprintf( $script ) ); |
|
1046 |
} |
|
5 | 1047 |
} |
1048 |
} |
|
1049 |
||
19 | 1050 |
/** |
1051 |
* Function display confirm |
|
1052 |
* |
|
1053 |
* @since 1.9.8 |
|
1054 |
*/ |
|
1055 |
if ( ! function_exists( 'bws_form_restore_default_confirm' ) ) { |
|
1056 |
function bws_form_restore_default_confirm( $plugin_basename ) { |
|
1057 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
<div> |
19 | 1059 |
<p><?php esc_html_e( 'Are you sure you want to restore default settings?', 'bestwebsoft' ); ?></p> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
<form method="post" action=""> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
<p> |
19 | 1062 |
<button class="button button-primary" name="bws_restore_confirm"><?php esc_html_e( 'Yes, restore all settings', 'bestwebsoft' ); ?></button> |
1063 |
<button class="button" name="bws_restore_deny"><?php esc_html_e( 'No, go back to the settings page', 'bestwebsoft' ); ?></button> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1064 |
<?php wp_nonce_field( $plugin_basename, 'bws_settings_nonce_name' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
</div> |
19 | 1068 |
<?php |
1069 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
|
19 | 1072 |
/** |
1073 |
* Function for shortcode |
|
1074 |
* |
|
1075 |
* @since 1.9.8 |
|
1076 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
if ( ! function_exists( 'bws_add_editor_buttons' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
function bws_add_editor_buttons() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
global $bws_shortcode_list; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
if ( ! empty( $bws_shortcode_list ) && current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
add_filter( 'mce_external_plugins', 'bws_add_buttons' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
add_filter( 'mce_buttons', 'bws_register_buttons' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
|
19 | 1087 |
/** |
1088 |
* Function add button for editor |
|
1089 |
* |
|
1090 |
* @since 1.9.8 |
|
1091 |
*/ |
|
1092 |
if ( ! function_exists( 'bws_add_buttons' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
function bws_add_buttons( $plugin_array ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
$plugin_array['add_bws_shortcode'] = bws_menu_url( 'js/shortcode-button.js' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
return $plugin_array; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
|
19 | 1099 |
/** |
1100 |
* Function register button for editor |
|
1101 |
* |
|
1102 |
* @since 1.9.8 |
|
1103 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
if ( ! function_exists( 'bws_register_buttons' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
function bws_register_buttons( $buttons ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
array_push( $buttons, 'add_bws_shortcode' ); /* dropcap', 'recentposts */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
return $buttons; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
|
19 | 1111 |
/** |
1112 |
* Function Generate inline content for the popup window when the "bws shortcode" button is clicked |
|
1113 |
* |
|
1114 |
* @since 1.9.8 |
|
1115 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
function bws_shortcode_media_button_popup() { |
16 | 1118 |
global $bws_shortcode_list; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
|
19 | 1120 |
if ( ! empty( $bws_shortcode_list ) ) { |
1121 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
<div id="bws_shortcode_popup" style="display:none;"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
<div id="bws_shortcode_popup_block"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
<div id="bws_shortcode_select_plugin"> |
19 | 1125 |
<h4><?php esc_html_e( 'Plugin', 'bestwebsoft' ); ?></h4> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
<select name="bws_shortcode_select" id="bws_shortcode_select"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
<?php foreach ( $bws_shortcode_list as $key => $value ) { ?> |
19 | 1128 |
<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['name'] ); ?></option> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
</select> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
<div class="clear"></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
<div id="bws_shortcode_content"> |
19 | 1134 |
<h4><?php esc_html_e( 'Shortcode settings', 'bestwebsoft' ); ?></h4> |
1135 |
<?php echo wp_kses_post( apply_filters( 'bws_shortcode_button_content', '' ) ); ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
<div class="clear"></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
<div id="bws_shortcode_content_bottom"> |
19 | 1139 |
<p><?php esc_html_e( 'The shortcode will be inserted', 'bestwebsoft' ); ?></p> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
<div id="bws_shortcode_block"><div id="bws_shortcode_display"></div></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
</div> |
19 | 1144 |
<?php |
1145 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
|
12 | 1149 |
/** |
19 | 1150 |
* Output shortcode in a special block |
1151 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
* @since 1.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
if ( ! function_exists( 'bws_shortcode_output' ) ) { |
19 | 1155 |
function bws_shortcode_output( $shortcode ) { |
1156 |
?> |
|
1157 |
<span class="bws_shortcode_output"><input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo esc_attr( $shortcode ); ?>" class="large-text bws_no_bind_notice"></span> |
|
1158 |
<?php |
|
1159 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
|
12 | 1162 |
/** |
19 | 1163 |
* Output tooltip |
1164 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
* @since 1.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
* @param string $content - HTML content for the tooltip |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
* @param string $class - Can be standart "bws-hide-for-mobile" (tooltip will be hidden in 782px) and "bws-auto-width" (need for img) or some custom class. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
if ( ! function_exists( 'bws_add_help_box' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
function bws_add_help_box( $content, $class = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1171 |
return '<span class="bws_help_box dashicons dashicons-editor-help ' . $class . ' hide-if-no-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
<span class="bws_hidden_help_text">' . $content . '</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1174 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
|
19 | 1177 |
/** |
1178 |
* Function add help tab |
|
1179 |
* |
|
1180 |
* @since 1.9.8 |
|
1181 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
if ( ! function_exists( 'bws_help_tab' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
function bws_help_tab( $screen, $args ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1184 |
$url = ( ! empty( $args['section'] ) ) ? 'https://support.bestwebsoft.com/hc/en-us/sections/' . $args['section'] : 'https://support.bestwebsoft.com/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1186 |
$content = '<p><a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Visit Help Center', 'bestwebsoft' ) . '</a></p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1187 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1188 |
$screen->add_help_tab( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1189 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1190 |
'id' => $args['id'] . '_help_tab', |
19 | 1191 |
'title' => esc_html__( 'FAQ', 'bestwebsoft' ), |
1192 |
'content' => wp_kses_post( $content ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1195 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1196 |
$screen->set_help_sidebar( |
19 | 1197 |
'<p><strong>' . esc_html__( 'For more information:', 'bestwebsoft' ) . '</strong></p>' . |
1198 |
'<p><a href="https://bestwebsoft.com/documentation/" target="_blank">' . esc_html__( 'Documentation', 'bestwebsoft' ) . '</a></p>' . |
|
1199 |
'<p><a href="https://www.youtube.com/user/bestwebsoft/playlists?flow=grid&sort=da&view=1" target="_blank">' . esc_html__( 'Video Instructions', 'bestwebsoft' ) . '</a></p>' . |
|
1200 |
'<p><a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . esc_html__( 'Submit a Request', 'bestwebsoft' ) . '</a></p>' |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1201 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1203 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1204 |
|
19 | 1205 |
/** |
1206 |
* Function add css and js |
|
1207 |
* |
|
1208 |
* @since 1.9.8 |
|
1209 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
if ( ! function_exists( 'bws_enqueue_custom_code_css_js' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
function bws_enqueue_custom_code_css_js() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1212 |
global $bstwbsftwppdtplgns_options; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
|
19 | 1214 |
if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
$bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
19 | 1216 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
$is_multisite = is_multisite(); |
19 | 1220 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
$blog_id = get_current_blog_id(); |
19 | 1222 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
|
19 | 1224 |
if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) { |
1225 |
wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'], array(), '2.4.2' ); |
|
1226 |
} elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) { |
|
1227 |
wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'], array(), '2.4.2' ); |
|
1228 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
|
19 | 1230 |
if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) { |
1231 |
wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'], array(), '2.4.2' ); |
|
1232 |
} elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) { |
|
1233 |
wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'], array(), '2.4.2' ); |
|
1234 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
|
19 | 1239 |
/** |
1240 |
* Function add custom php code |
|
1241 |
* |
|
1242 |
* @since 1.9.8 |
|
1243 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
if ( ! function_exists( 'bws_enqueue_custom_code_php' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
function bws_enqueue_custom_code_php() { |
19 | 1246 |
if ( is_admin() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
return; |
19 | 1248 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1249 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
global $bstwbsftwppdtplgns_options; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
|
19 | 1252 |
if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
$bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
19 | 1254 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
$is_multisite = is_multisite(); |
19 | 1259 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
$blog_id = get_current_blog_id(); |
19 | 1261 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
if ( file_exists( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { |
19 | 1265 |
if ( ! defined( 'BWS_GLOBAL' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
define( 'BWS_GLOBAL', true ); |
19 | 1267 |
} |
1268 |
require_once $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
unset( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); |
19 | 1271 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 1273 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 1275 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
} elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
if ( file_exists( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { |
19 | 1279 |
if ( ! defined( 'BWS_GLOBAL' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
define( 'BWS_GLOBAL', true ); |
19 | 1281 |
} |
1282 |
require_once $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); |
19 | 1285 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 1287 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1288 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 1289 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1290 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
|
19 | 1296 |
/** |
1297 |
* Function delete plugin |
|
1298 |
* |
|
1299 |
* @since 1.9.8 |
|
1300 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
if ( ! function_exists( 'bws_delete_plugin' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
function bws_delete_plugin( $basename ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
global $bstwbsftwppdtplgns_options; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
$is_multisite = is_multisite(); |
19 | 1306 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
$blog_id = get_current_blog_id(); |
19 | 1308 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
|
19 | 1310 |
if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
$bstwbsftwppdtplgns_options = ( $is_multisite ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
19 | 1312 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
/* remove bws_menu versions */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $basename ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
/* remove track usage data */ |
19 | 1317 |
if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
unset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ); |
19 | 1319 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
/* if empty ['bws_menu']['version'] - there is no other bws plugins - delete all */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
if ( empty( $bstwbsftwppdtplgns_options['bws_menu']['version'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
/* remove options */ |
19 | 1323 |
if ( $is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
delete_site_option( 'bstwbsftwppdtplgns_options' ); |
19 | 1325 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
delete_option( 'bstwbsftwppdtplgns_options' ); |
19 | 1327 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
/* remove custom_code */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
if ( $is_multisite ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
global $wpdb; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
$old_blog = $wpdb->blogid; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
/* Get all blog ids */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
$blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
foreach ( $blogids as $blog_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
switch_to_blog( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
$upload_dir = wp_upload_dir(); |
19 | 1338 |
$folder = $upload_dir['basedir'] . '/bws-custom-code'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
if ( file_exists( $folder ) && is_dir( $folder ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
array_map( 'unlink', glob( "$folder/*" ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1341 |
rmdir( $folder ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1343 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
switch_to_blog( $old_blog ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
$upload_dir = wp_upload_dir(); |
19 | 1347 |
$folder = $upload_dir['basedir'] . '/bws-custom-code'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
if ( file_exists( $folder ) && is_dir( $folder ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
array_map( 'unlink', glob( "$folder/*" ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
rmdir( $folder ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
add_action( 'admin_init', 'bws_plugins_admin_init' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
add_action( 'admin_enqueue_scripts', 'bws_admin_enqueue_scripts' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
add_action( 'admin_head', 'bws_plugins_admin_head' ); |
19 | 1360 |
add_action( 'admin_footer', 'bws_plugins_admin_footer' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
add_action( 'admin_notices', 'bws_admin_notices', 30 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1364 |
add_action( 'wp_enqueue_scripts', 'bws_enqueue_custom_code_css_js', 20 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
|
16 | 1366 |
bws_enqueue_custom_code_php(); |