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