| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Five Star Business Profile and Schema |
| 4 |
* Plugin URI: https://www.fivestarplugins.com/plugins/business-profile/ |
| 5 |
* Description: Add schema structured data to any page or post type. Create an SEO friendly contact card with your business info and associated schema. Supports Google Map, opening hours and more. |
| 6 |
* Version: 2.3.21 |
| 7 |
* Author: Five Star Plugins |
| 8 |
* Author URI: https://www.fivestarplugins.com |
| 9 |
* License: GPLv3 |
| 10 |
* License URI:http://www.gnu.org/licenses/gpl-3.0.html |
| 11 |
* |
| 12 |
* Text Domain: business-profile |
| 13 |
* Domain Path: /languages/ |
| 14 |
*/ |
| 15 |
|
| 16 |
defined( 'ABSPATH' ) || exit; |
| 17 |
|
| 18 |
if ( ! class_exists( 'bpfwpInit', false ) ) : |
| 19 |
|
| 20 |
class bpfwpInit { |
| 21 |
|
| 22 |
// pointers to classes used by the plugin, where needed |
| 23 |
public $blocks; |
| 24 |
public $cpts; |
| 25 |
public $patterns; |
| 26 |
public $permissions; |
| 27 |
public $schemas; |
| 28 |
public $settings; |
| 29 |
|
| 30 |
/** |
| 31 |
* Settings for displaying the contact card currently being handled. |
| 32 |
* |
| 33 |
* @since 0.0.1 |
| 34 |
* @access public |
| 35 |
* @var array |
| 36 |
*/ |
| 37 |
public $display_settings = array(); |
| 38 |
|
| 39 |
|
| 40 |
/** |
| 41 |
* Initialize the plugin and register hooks. |
| 42 |
* |
| 43 |
* @since 0.0.1 |
| 44 |
* @access public |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
public function __construct() { |
| 48 |
|
| 49 |
self::constants(); |
| 50 |
self::includes(); |
| 51 |
self::instantiate(); |
| 52 |
self::wp_hooks(); |
| 53 |
if ( $this->settings->get_setting( 'multiple-locations' ) ) { |
| 54 |
register_activation_hook( __FILE__, array( $this->cpts, 'flush_rewrite_rules' ) ); |
| 55 |
} |
| 56 |
|
| 57 |
// Add the admin menu |
| 58 |
add_action( 'admin_menu', array( $this, 'add_menu_page' ) ); |
| 59 |
|
| 60 |
// Add a link to the Google Rich Results Test Page for front-end pages |
| 61 |
add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_link' ), 100 ); |
| 62 |
} |
| 63 |
|
| 64 |
public function add_menu_page() { |
| 65 |
add_menu_page( |
| 66 |
__( 'Business Profile', 'business-profile' ), |
| 67 |
__( 'Business Profile', 'business-profile' ), |
| 68 |
'manage_options', |
| 69 |
'bpfwp-business-profile', |
| 70 |
'', |
| 71 |
'dashicons-businessperson', |
| 72 |
51 |
| 73 |
); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Add a link to the Google Rich Results Test Page to front-end pages |
| 78 |
* |
| 79 |
* @since 2.1.0 |
| 80 |
* @return void |
| 81 |
*/ |
| 82 |
public function add_admin_bar_link( $admin_bar ) { |
| 83 |
|
| 84 |
if ( is_admin() ) { return; } |
| 85 |
|
| 86 |
$admin_bar->add_node( |
| 87 |
array( |
| 88 |
'id' => 'business_profile_test_link', |
| 89 |
'title' => 'Test Schema', |
| 90 |
'href' => 'https://search.google.com/test/rich-results?url=' . get_the_permalink(), |
| 91 |
'meta' => array( |
| 92 |
'target' => 'blank', |
| 93 |
'title' => 'View Google Schema Test Results' |
| 94 |
) |
| 95 |
) |
| 96 |
); |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Define plugin constants. |
| 101 |
* |
| 102 |
* @since 1.1.0 |
| 103 |
* @access protected |
| 104 |
* @return void |
| 105 |
*/ |
| 106 |
protected function constants() { |
| 107 |
define( 'BPFWP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
| 108 |
define( 'BPFWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) ); |
| 109 |
define( 'BPFWP_PLUGIN_FNAME', plugin_basename( __FILE__ ) ); |
| 110 |
define( 'BPFWP_VERSION', '2.3.21' ); |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Include all plugin files. |
| 115 |
* |
| 116 |
* @since 1.1.0 |
| 117 |
* @access protected |
| 118 |
* @return void |
| 119 |
*/ |
| 120 |
protected function includes() { |
| 121 |
|
| 122 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-about-us.php'; |
| 123 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-blocks.php'; |
| 124 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-dashboard.php'; |
| 125 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-patterns.php'; |
| 126 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-compatibility.php'; |
| 127 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-admin-custom-fields.php'; |
| 128 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-custom-post-types.php'; |
| 129 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-deactivation-survey.php'; |
| 130 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-helper.php'; |
| 131 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-installation-walkthrough.php'; |
| 132 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-integrations.php'; |
| 133 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-permissions.php'; |
| 134 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-review-ask.php'; |
| 135 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-schemas-manager.php'; |
| 136 |
require_once BPFWP_PLUGIN_DIR . '/includes/schemas/class-schema.php'; |
| 137 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-settings.php'; |
| 138 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-template-loader.php'; |
| 139 |
require_once BPFWP_PLUGIN_DIR . '/includes/template-functions.php'; |
| 140 |
require_once BPFWP_PLUGIN_DIR . '/includes/helper-functions.php'; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Spin up instances of our plugin classes. |
| 145 |
* |
| 146 |
* @since 1.1.0 |
| 147 |
* @access protected |
| 148 |
* @return void |
| 149 |
*/ |
| 150 |
protected function instantiate() { |
| 151 |
|
| 152 |
new bpfwpCompatibility(); |
| 153 |
new bpfwpAdminCustomFields(); |
| 154 |
new bpfwpIntegrations(); // Deprecated in v1.1. |
| 155 |
new bpfwpDeactivationSurvey(); |
| 156 |
new bpfwpDashboard(); |
| 157 |
new bpfwpReviewAsk(); |
| 158 |
new bpfwpInstallationWalkthrough(); |
| 159 |
|
| 160 |
$this->permissions = new bpfwpPermissions(); |
| 161 |
$this->schemas = new bpfwpSchemasManager(); |
| 162 |
$this->settings = new bpfwpSettings(); |
| 163 |
$this->cpts = new bpfwpCustomPostTypes(); |
| 164 |
|
| 165 |
$this->blocks = new bpfwpBlocks(); |
| 166 |
if ( function_exists( 'register_block_pattern' ) ) { $this->patterns = new bpfwpPatterns(); } |
| 167 |
|
| 168 |
|
| 169 |
$this->blocks->run(); |
| 170 |
$this->cpts->run( $this->settings->get_setting('multiple-locations') ); |
| 171 |
|
| 172 |
new bpfwpAboutUs(); |
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* Hook into WordPress. |
| 177 |
* |
| 178 |
* @since 1.1.0 |
| 179 |
* @access protected |
| 180 |
* @return void |
| 181 |
*/ |
| 182 |
protected function wp_hooks() { |
| 183 |
register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) ); |
| 184 |
|
| 185 |
add_action( 'plugins_loaded', array( $this, 'plugin_loaded_action_hook' ) ); |
| 186 |
add_action( 'load_textdomain', array( $this, 'load_textdomain' ) ); |
| 187 |
add_action( 'admin_notices', array( $this, 'display_header_area'), 99 ); |
| 188 |
add_action( 'admin_notices', array( $this, 'maybe_display_helper_notice' ) ); |
| 189 |
add_action( 'admin_notices', array( $this, 'maybe_display_new_plugin_notice' ) ); |
| 190 |
add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) ); |
| 191 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); |
| 192 |
add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
| 193 |
add_filter( 'the_content', array( $this, 'append_to_content' ) ); |
| 194 |
add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); |
| 195 |
|
| 196 |
add_action( 'wp_ajax_bpfwp_hide_helper_notice', array( $this, 'hide_helper_notice' ) ); |
| 197 |
add_action( 'wp_ajax_bpfwp_hide_new_plugin_notice', array( $this, 'hide_new_plugin_notice' ) ); |
| 198 |
} |
| 199 |
|
| 200 |
/** |
| 201 |
* Allow third-party plugins to interact with the plugin, if necessary |
| 202 |
* |
| 203 |
* @since 2.2.0 |
| 204 |
* @access public |
| 205 |
* @return void |
| 206 |
*/ |
| 207 |
public function plugin_loaded_action_hook() { |
| 208 |
|
| 209 |
do_action( 'bpfwp_initialized' ); |
| 210 |
} |
| 211 |
|
| 212 |
/** |
| 213 |
* Load the plugin textdomain for localistion. |
| 214 |
* |
| 215 |
* @since 0.0.1 |
| 216 |
* @access public |
| 217 |
* @return void |
| 218 |
*/ |
| 219 |
public function load_textdomain() { |
| 220 |
load_plugin_textdomain( |
| 221 |
'business-profile', |
| 222 |
false, |
| 223 |
plugin_basename( dirname( __FILE__ ) ) . '/languages' |
| 224 |
); |
| 225 |
} |
| 226 |
|
| 227 |
/** |
| 228 |
* Set a transient so that the walk-through gets run |
| 229 |
* @since 2.3.4 |
| 230 |
*/ |
| 231 |
public function run_walkthrough() { |
| 232 |
|
| 233 |
set_transient( 'bpfwp-getting-started', true, 30 ); |
| 234 |
} |
| 235 |
|
| 236 |
/** |
| 237 |
* Register the front-end CSS styles |
| 238 |
* |
| 239 |
* @since 0.0.1 |
| 240 |
* @access public |
| 241 |
* @return void |
| 242 |
*/ |
| 243 |
function register_assets() { |
| 244 |
wp_register_style( |
| 245 |
'bpfwp-default', |
| 246 |
BPFWP_PLUGIN_URL . '/assets/css/contact-card.css', |
| 247 |
null, |
| 248 |
BPFWP_VERSION |
| 249 |
); |
| 250 |
wp_register_script( |
| 251 |
'bpfwp-map', |
| 252 |
BPFWP_PLUGIN_URL . '/assets/js/map.js', |
| 253 |
array( 'jquery' ), |
| 254 |
BPFWP_VERSION, |
| 255 |
true |
| 256 |
); |
| 257 |
} |
| 258 |
|
| 259 |
/** |
| 260 |
* Register the widgets |
| 261 |
* |
| 262 |
* @since 0.0.1 |
| 263 |
* @access public |
| 264 |
* @return void |
| 265 |
*/ |
| 266 |
public function register_widgets() { |
| 267 |
require_once BPFWP_PLUGIN_DIR . '/includes/class-contact-card-widget.php'; |
| 268 |
register_widget( 'bpfwpContactCardWidget' ); |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
public function display_header_area() { |
| 273 |
global $bpfwp_controller, $post; |
| 274 |
|
| 275 |
$screen = get_current_screen(); |
| 276 |
$screenID = $screen->id; |
| 277 |
$screenPostType = $screen->post_type; |
| 278 |
$settings = get_option( 'bpfwp-settings', array() ); |
| 279 |
|
| 280 |
if ( strpos( $screenID, 'bpfwp' ) === false && $screenPostType != 'location' && $screenPostType != 'schema' ) {return;} |
| 281 |
|
| 282 |
if ( ! $bpfwp_controller->permissions->check_permission( 'premium' ) || get_option("BPFWP_Trial_Happening") == "Yes" ) { |
| 283 |
?> |
| 284 |
<div class="bpfwp-dashboard-new-upgrade-banner"> |
| 285 |
<div class="bpfwp-dashboard-banner-icon"></div> |
| 286 |
<div class="bpfwp-dashboard-banner-buttons"> |
| 287 |
<a class="bpfwp-dashboard-new-upgrade-button" href="https://www.fivestarplugins.com/license-payment/?Selected=BPFWP&Quantity=1&utm_source=bpfwp_admin&utm_content=banner" target="_blank">UPGRADE NOW</a> |
| 288 |
</div> |
| 289 |
<div class="bpfwp-dashboard-banner-text"> |
| 290 |
<div class="bpfwp-dashboard-banner-title"> |
| 291 |
GET FULL ACCESS WITH OUR PREMIUM VERSION |
| 292 |
</div> |
| 293 |
<div class="bpfwp-dashboard-banner-brief"> |
| 294 |
Automatic schema integration into posts and with other plugins, multiple locations and more! |
| 295 |
</div> |
| 296 |
</div> |
| 297 |
</div> |
| 298 |
<?php |
| 299 |
} |
| 300 |
|
| 301 |
?> |
| 302 |
<div class="bpfwp-admin-header-menu"> |
| 303 |
<h2 class="nav-tab-wrapper"> |
| 304 |
<a id="bpfwp-dash-mobile-menu-open" href="#" class="menu-tab nav-tab"><?php _e("MENU", 'business-profile'); ?><span id="bpfwp-dash-mobile-menu-down-caret"> ▼</span><span id="bpfwp-dash-mobile-menu-up-caret"> ▲</span></a> |
| 305 |
<a id="dashboard-menu" href='admin.php?page=bpfwp-dashboard' class="menu-tab nav-tab <?php if ($screenID == 'business-profile_page_bpfwp-dashboard') {echo 'nav-tab-active';}?>"><?php _e("Dashboard", 'business-profile'); ?></a> |
| 306 |
<?php if ( ! empty( $settings['multiple-locations'] ) ) { ?> |
| 307 |
<a id="locations-menu" href='edit.php?post_type=location' class="menu-tab nav-tab <?php if ($screenID == 'edit-location') {echo 'nav-tab-active';}?>"><?php _e("Locations", 'business-profile'); ?></a> |
| 308 |
<?php } ?> |
| 309 |
<a id="schemas-menu" href='edit.php?post_type=schema' class="menu-tab nav-tab <?php if ($screenID == 'edit-schema') {echo 'nav-tab-active';}?>"><?php _e("Schemas", 'business-profile'); ?></a> |
| 310 |
<a id="options-menu" href='admin.php?page=bpfwp-settings' class="menu-tab nav-tab <?php if ($screenID == 'business-profile_page_bpfwp-settings') {echo 'nav-tab-active';}?>"><?php _e("Settings", 'business-profile'); ?></a> |
| 311 |
<?php if ( ! empty( $settings['custom-fields'] ) ){ ?> |
| 312 |
<a id="custom-fields-menu" href='admin.php?page=bpfwp-custom-fields' class="menu-tab nav-tab <?php if ($screenID == 'business-profile_page_bpfwp-custom-fields') {echo 'nav-tab-active';}?>"><?php _e("Custom Fields", 'business-profile'); ?></a> |
| 313 |
<?php } ?> |
| 314 |
</h2> |
| 315 |
</div> |
| 316 |
<?php |
| 317 |
} |
| 318 |
|
| 319 |
/** |
| 320 |
* Enqueue the admin CSS for locations |
| 321 |
* |
| 322 |
* @since 1.1 |
| 323 |
* @access public |
| 324 |
* @global WP_Post $post The current WordPress post object. |
| 325 |
* @param string $hook_suffix The current admin screen slug. |
| 326 |
* @return void |
| 327 |
*/ |
| 328 |
public function enqueue_admin_assets( $hook_suffix ) { |
| 329 |
|
| 330 |
global $post; |
| 331 |
$screen = get_current_screen(); |
| 332 |
$screenPostType = $screen->post_type; |
| 333 |
|
| 334 |
wp_enqueue_script( 'bpfwp-helper-notice', BPFWP_PLUGIN_URL . '/assets/js/helper-install-notice.js', array( 'jquery' ), BPFWP_VERSION, true ); |
| 335 |
wp_localize_script( |
| 336 |
'bpfwp-helper-notice', |
| 337 |
'bpfwp_helper_notice', |
| 338 |
array( 'nonce' => wp_create_nonce( 'bpfwp-helper-notice' ) ) |
| 339 |
); |
| 340 |
|
| 341 |
wp_enqueue_style( 'bpfwp-helper-notice', BPFWP_PLUGIN_URL . '/assets/css/helper-install-notice.css', array(), BPFWP_VERSION ); |
| 342 |
|
| 343 |
if ( |
| 344 |
'post-new.php' === $hook_suffix |
| 345 |
|| 'post.php' === $hook_suffix |
| 346 |
|| $screenPostType == 'location' |
| 347 |
|| $screenPostType == 'schema' |
| 348 |
|| strpos( $screen->id, 'bpfwp' ) !== false |
| 349 |
) { |
| 350 |
wp_enqueue_style( 'bpfwp-admin-location', BPFWP_PLUGIN_URL . '/assets/css/admin.css', array(), BPFWP_VERSION ); |
| 351 |
wp_enqueue_script( 'bpfwp-admin-js', BPFWP_PLUGIN_URL . '/assets/js/admin.js', array( 'jquery' ), BPFWP_VERSION, true ); |
| 352 |
|
| 353 |
$args = array( |
| 354 |
'nonce' => wp_create_nonce( 'bpfwp-admin-js' ), |
| 355 |
); |
| 356 |
|
| 357 |
wp_localize_script( 'bpfwp-admin-js', 'bpfwp_php_admin_data', $args ); |
| 358 |
|
| 359 |
} |
| 360 |
} |
| 361 |
|
| 362 |
/** |
| 363 |
* Add links to the plugin listing on the installed plugins page |
| 364 |
* |
| 365 |
* @since 0.0.1 |
| 366 |
* @access public |
| 367 |
* @param array $links The current plugin action links. |
| 368 |
* @param string $plugin The current plugin slug. |
| 369 |
* @return array $links Modified action links. |
| 370 |
*/ |
| 371 |
public function plugin_action_links( $links, $plugin ) { |
| 372 |
global $bpfwp_controller; |
| 373 |
|
| 374 |
if ( BPFWP_PLUGIN_FNAME === $plugin ) { |
| 375 |
|
| 376 |
if ( ! $bpfwp_controller->permissions->check_permission( 'premium' ) ) { |
| 377 |
|
| 378 |
array_unshift( $links, '<a class="bpfwp-plugin-page-upgrade-link" href="https://www.fivestarplugins.com/license-payment/?Selected=BPFWP&Quantity=1&utm_source=wp_admin_plugins_page" title="' . __( 'Try Premium', 'business-profile' ) . '" target="_blank">' . __( 'Try Premium', 'business-profile' ) . '</a>' ); |
| 379 |
} |
| 380 |
|
| 381 |
$links['help'] = sprintf( '<a href="https://doc.fivestarplugins.com/plugins/business-profile/" title="%s">%s</a>', |
| 382 |
__( 'View the help documentation for Business Profile', 'business-profile' ), |
| 383 |
__( 'Help', 'business-profile' ) |
| 384 |
); |
| 385 |
} |
| 386 |
|
| 387 |
return $links; |
| 388 |
} |
| 389 |
|
| 390 |
/** |
| 391 |
* Retrieve the get_theme_supports() value for a feature |
| 392 |
* |
| 393 |
* @since 1.1 |
| 394 |
* @access public |
| 395 |
* @param string $feature A theme support feature to get. |
| 396 |
* @return bool Whether or not a feature is supported. |
| 397 |
*/ |
| 398 |
public function get_theme_support( $feature ) { |
| 399 |
|
| 400 |
$theme_support = get_theme_support( 'business-profile' ); |
| 401 |
|
| 402 |
if ( true === $theme_support ) { |
| 403 |
return true; |
| 404 |
} elseif ( false === $theme_support ) { |
| 405 |
return false; |
| 406 |
} else { |
| 407 |
$theme_support = (array) $theme_support; |
| 408 |
$theme_support = array_shift( $theme_support ); |
| 409 |
return isset( $theme_support[ $feature ] ) && true === $theme_support[ $feature ]; |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
/** |
| 414 |
* Append contact card to a post's $content variable |
| 415 |
* @since 2.0.8 |
| 416 |
*/ |
| 417 |
function append_to_content( $content ) { |
| 418 |
global $post; |
| 419 |
|
| 420 |
if ( !is_main_query() || !in_the_loop() || post_password_required() ) { |
| 421 |
return $content; |
| 422 |
} |
| 423 |
|
| 424 |
if ( $post->ID == $this->settings->get_setting( 'contact-page' ) and ! $this->settings->get_setting( 'disable-contact-page-card' ) ) { |
| 425 |
return $content . bpwfwp_print_contact_card(); |
| 426 |
} |
| 427 |
|
| 428 |
return $content; |
| 429 |
} |
| 430 |
|
| 431 |
public function maybe_display_helper_notice() { |
| 432 |
global $bpfwp_controller; |
| 433 |
|
| 434 |
if ( empty( $bpfwp_controller->permissions->check_permission( 'premium' ) ) ) { return; } |
| 435 |
|
| 436 |
if ( is_plugin_active( 'fsp-premium-helper/fsp-premium-helper.php' ) ) { return; } |
| 437 |
|
| 438 |
if ( get_transient( 'fsp-helper-notice-dismissed' ) ) { return; } |
| 439 |
|
| 440 |
?> |
| 441 |
|
| 442 |
<div class='notice notice-error is-dismissible bpfwp-helper-install-notice'> |
| 443 |
|
| 444 |
<div class='bpfwp-helper-install-notice-img'> |
| 445 |
<img src='<?php echo BPFWP_PLUGIN_URL . '/lib/simple-admin-pages/img/options-asset-exclamation.png' ; ?>' /> |
| 446 |
</div> |
| 447 |
|
| 448 |
<div class='bpfwp-helper-install-notice-txt'> |
| 449 |
<?php _e( 'You\'re using the Five-Star Business Profile premium version, but the premium helper plugin is not active.', 'business-profile' ); ?> |
| 450 |
<br /> |
| 451 |
<?php echo sprintf( __( 'Please re-activate the helper plugin, or <a target=\'_blank\' href=\'%s\'>download and install it</a> if the plugin is no longer installed to ensure continued access to the premium features of the plugin.', 'business-profile' ), 'https://www.fivestarplugins.com/2021/12/23/requiring-premium-helper-plugin/' ); ?> |
| 452 |
</div> |
| 453 |
|
| 454 |
<div class='bpfwp-clear'></div> |
| 455 |
|
| 456 |
</div> |
| 457 |
|
| 458 |
<?php |
| 459 |
} |
| 460 |
|
| 461 |
public function hide_helper_notice() { |
| 462 |
|
| 463 |
// Authenticate request |
| 464 |
if ( ! check_ajax_referer( 'bpfwp-helper-notice', 'nonce' ) or ! current_user_can( 'manage_options' ) ) { |
| 465 |
|
| 466 |
wp_send_json_error( |
| 467 |
array( |
| 468 |
'error' => 'loggedout', |
| 469 |
'msg' => sprintf( __( 'You have been logged out. Please %slogin again%s.', 'business-profile' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=bpfwp-dashboard' ) ) . '">', '</a>' ), |
| 470 |
) |
| 471 |
); |
| 472 |
} |
| 473 |
|
| 474 |
set_transient( 'fsp-helper-notice-dismissed', true, 3600*24*7 ); |
| 475 |
|
| 476 |
die(); |
| 477 |
} |
| 478 |
|
| 479 |
public function maybe_display_new_plugin_notice() { |
| 480 |
|
| 481 |
if ( ! current_user_can( 'activate_plugins' ) ) { return; } |
| 482 |
|
| 483 |
$screen = get_current_screen(); |
| 484 |
|
| 485 |
if ( ! isset( $screen->id ) ) { return; } |
| 486 |
|
| 487 |
$allowed_screens = array( |
| 488 |
'plugins', |
| 489 |
'update-core', |
| 490 |
'dashboard', |
| 491 |
'options-general', |
| 492 |
'options-writing', |
| 493 |
'options-reading', |
| 494 |
'options-discussion', |
| 495 |
'options-media', |
| 496 |
'options-permalink', |
| 497 |
'options-privacy' |
| 498 |
); |
| 499 |
|
| 500 |
if ( strpos( $screen->id, 'profile_page_' ) === false and |
| 501 |
! in_array( $screen->id, $allowed_screens ) ) { |
| 502 |
return; |
| 503 |
} |
| 504 |
|
| 505 |
if ( get_transient( 'ait-aiaa-plugin-notice-dismissed' ) ) { return; } |
| 506 |
|
| 507 |
// May 22nd, 2026 |
| 508 |
if ( time() > 1779508748 ) { return; } |
| 509 |
|
| 510 |
$hook_lines = array( |
| 511 |
__( 'Tired of digging through settings? Let <strong>AI Admin Assistance</strong> guide you!', 'business-profile' ), |
| 512 |
__( 'Stop wasting time searching for answers—use <strong>AI Admin Assistance</strong> to bring AI-powered help directly into your dashboard!', 'business-profile' ), |
| 513 |
__( 'Overwhelmed in the WordPress admin? <strong>AI Admin Assistance</strong> has you covered with AI-powered help directly in your dashboard!', 'business-profile' ), |
| 514 |
); |
| 515 |
|
| 516 |
$selection = array_rand( $hook_lines ); |
| 517 |
|
| 518 |
?> |
| 519 |
|
| 520 |
<div class='notice notice-error is-dismissible ait-aiaa-new-plugin-notice'> |
| 521 |
|
| 522 |
<div class='bpfwp-new-plugin-notice-img'> |
| 523 |
<img src='<?php echo BPFWP_PLUGIN_URL . '/assets/img/ait-aiaa-plugin-icon.png' ; ?>' /> |
| 524 |
</div> |
| 525 |
|
| 526 |
<div class='bpfwp-new-plugin-notice-txt'> |
| 527 |
<p><?php echo $hook_lines[ $selection ]; ?></p> |
| 528 |
<p><?php echo sprintf( __( 'As a thank you to our customers, for a limited time you can get a <strong>free pro license</strong>! Try the <a target=\'_blank\' href=\'%s\'>free version</a> today or use code <code>early_adopter_pro</code> to <a target=\'_blank\' href=\'%s\'>get your pro version license</a>!', 'business-profile' ), admin_url( 'plugin-install.php?tab=plugin-information&plugin=ait-ai-admin-assistance' ), 'https://www.wpaiplugins.dev/wordpress-ai-admin-assistance/?utm_source=' . dirname( BPFWP_PLUGIN_FNAME ) . '_aiaa_notice&utm_content=' . $selection ); ?></p> |
| 529 |
</div> |
| 530 |
|
| 531 |
<div class='bpfwp-clear'></div> |
| 532 |
|
| 533 |
</div> |
| 534 |
|
| 535 |
<?php |
| 536 |
} |
| 537 |
|
| 538 |
public function hide_new_plugin_notice() { |
| 539 |
global $bpfwp_controller; |
| 540 |
|
| 541 |
// Authenticate request |
| 542 |
if ( |
| 543 |
! check_ajax_referer( 'bpfwp-helper-notice', 'nonce' ) |
| 544 |
|| |
| 545 |
! current_user_can( 'manage_options' ) |
| 546 |
) { |
| 547 |
wp_send_json_error( |
| 548 |
array( |
| 549 |
'error' => 'loggedout', |
| 550 |
'msg' => sprintf( __( 'You have been logged out. Please %slogin again%s.', 'business-profile' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=bpfwp-dashboard' ) ) . '">', '</a>' ), |
| 551 |
) |
| 552 |
); |
| 553 |
|
| 554 |
} |
| 555 |
|
| 556 |
set_transient( 'ait-aiaa-plugin-notice-dismissed', true, 3600*24*7 ); |
| 557 |
|
| 558 |
die(); |
| 559 |
} |
| 560 |
|
| 561 |
/** |
| 562 |
* Return a single instance of the main plugin class. |
| 563 |
* |
| 564 |
* Developers and tests may still create multiple instances by spinning |
| 565 |
* them up directly, but for most uses, this method is preferred. |
| 566 |
* |
| 567 |
* @since 1.1.0 |
| 568 |
* @access public |
| 569 |
* @static |
| 570 |
* @return object bpfwpInit A single instance of the main plugin class. |
| 571 |
*/ |
| 572 |
public static function instance() { |
| 573 |
static $instance; |
| 574 |
if ( null === $instance ) { |
| 575 |
$instance = new self; |
| 576 |
} |
| 577 |
return $instance; |
| 578 |
} |
| 579 |
} |
| 580 |
endif; |
| 581 |
|
| 582 |
global $bpfwp_controller; |
| 583 |
$bpfwp_controller = bpfwpInit::instance(); |