| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?php
- /**
- * Handles displaying promotional text throughout plugin UI
- */
- class PUM_Upsell {
- /**
- * Hooks any needed methods
- */
- public static function init() {
- add_filter( 'views_edit-popup', array( __CLASS__, 'addon_tabs' ), 10, 1 );
- add_filter( 'views_edit-popup_theme', array( __CLASS__, 'addon_tabs' ), 10, 1 );
- add_filter( 'pum_popup_settings_fields', array( __CLASS__, 'popup_promotional_fields' ) );
- add_filter( 'pum_theme_settings_fields', array( __CLASS__, 'theme_promotional_fields' ) );
- add_action( 'in_admin_header', array( __CLASS__, 'notice_bar_display' ) );
- }
- /**
- * Adds a small notice bar in PM admin areas when not using any extensions
- *
- * @since 1.14.0
- */
- public static function notice_bar_display() {
- if ( pum_is_all_popups_page() && 0 === count( pum_enabled_extensions() ) ) {
- $message = sprintf(
- /* translators: %s - Wraps ending in link to pricing page. */
- esc_html__( 'You are using the free version of Popup Maker. To get even more value, consider %1$supgrading to our premium plans%2$s.', 'popup-maker' ),
- '<a href="https://wppopupmaker.com/pricing/?utm_source=upsell-notice-bar&utm_medium=text-link&utm_campaign=upsell" target="_blank" rel="noopener noreferrer">',
- '</a>'
- );
- ?>
- <div class="pum-notice-bar-wrapper">
- <div class="pum-notice-bar">
- <span class="pum-notice-bar-message">
- <?php
- echo wp_kses(
- $message,
- array(
- 'a' => array(
- 'href' => array(),
- 'rel' => array(),
- 'target' => array(),
- ),
- )
- );
- ?>
- </span>
- </div>
- </div>
- <?php
- }
- }
- /**
- * Adds messages throughout Popup Settings UI
- *
- * @param array $tabs The tabs/fields for popup settings.
- * @return array
- */
- public static function popup_promotional_fields( $tabs = array() ) {
- if ( ! pum_extension_enabled( 'forced-interaction' ) ) {
- /* translators: %s url to product page. */
- $message = sprintf( __( 'Want to disable the close button? Check out <a href="%s" target="_blank">Forced Interaction</a>!', 'popup-maker' ), 'https://wppopupmaker.com/extensions/forced-interaction/?utm_source=plugin-theme-editor&utm_medium=text-link&utm_campaign=upsell&utm_content=close-button-settings' );
- $tabs['close']['button']['fi_promotion'] = $tabs['close']['forms']['fi_promotion'] = $tabs['close']['alternate_methods']['fi_promotion'] = array(
- 'type' => 'html',
- 'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-forced-interaction.png' ) . '" />' . $message,
- 'priority' => 999,
- 'class' => 'pum-upgrade-tip',
- );
- }
- if ( ! pum_extension_enabled( 'advanced-targeting-conditions' ) ) {
- /* translators: %s url to product page. */
- $message = sprintf( __( 'Need more <a href="%s" target="_blank">advanced targeting</a> options?', 'popup-maker' ), 'https://wppopupmaker.com/extensions/advanced-targeting-conditions/?utm_campaign=upsell&utm_source=plugin-popup-editor&utm_medium=text-link&utm_content=conditions-editor' );
- $tabs['targeting']['main']['atc_promotion'] = array(
- 'type' => 'html',
- 'content' => '<img src="' . pum_asset_url( 'images/logo.png' ) . '" height="28" />' . $message,
- 'priority' => 999,
- 'class' => 'pum-upgrade-tip',
- );
- }
- return $tabs;
- }
- /**
- * Adds messages throughout Popup Theme UI
- *
- * @param array $tabs The tabs/fields for popup theme.
- * @return array
- */
- public static function theme_promotional_fields( $tabs = array() ) {
- if ( ! pum_extension_enabled( 'advanced-theme-builder' ) && ! class_exists( 'PUM_ATB' ) ) {
- foreach ( array( 'overlay', 'container', 'close' ) as $tab ) {
- /* translators: %s url to product page. */
- $message = __( 'Want to use <a href="%s" target="_blank">background images</a>?', 'popup-maker' );
- $tabs[ $tab ]['background']['atc_promotion'] = array(
- 'type' => 'html',
- 'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-advanted-theme-builder.png' ) . '" height="28" />' . sprintf( $message, 'https://wppopupmaker.com/extensions/advanced-theme-builder/?utm_campaign=upsell&utm_source=plugin-theme-editor&utm_medium=text-link&utm_content=' . $tab . '-settings' ),
- 'priority' => 999,
- 'class' => 'pum-upgrade-tip',
- );
- }
- }
- return $tabs;
- }
- /**
- * When the Popup or Popup Theme list table loads, call the function to view our tabs.
- *
- * @since 1.8.0
- * @param array $views An array of available list table views.
- * @return mixed
- */
- public static function addon_tabs( $views ) {
- self::display_addon_tabs();
- return $views;
- }
- /**
- * Displays the tabs for 'Popups', 'Popup Themes' and 'Extensions and Integrations'
- *
- * @since 1.8.0
- */
- public static function display_addon_tabs() {
- $popup_labels = PUM_Types::post_type_labels( __( 'Popup', 'popup-maker' ), __( 'Popups', 'popup-maker' ) );
- $theme_labels = PUM_Types::post_type_labels( __( 'Popup Theme', 'popup-maker' ), __( 'Popup Themes', 'popup-maker' ) );
- ?>
- <style>
- .wrap h1.wp-heading-inline + a.page-title-action {
- display: none;
- }
- .edit-php.post-type-popup .wrap .nav-tab-wrapper .page-title-action, .edit-php.post-type-popup_theme .wrap .nav-tab-wrapper .page-title-action, .popup_page_pum-extensions .wrap .nav-tab-wrapper .page-title-action {
- top: 7px;
- margin-left: 5px
- }
- @media only screen and (min-width: 0px) and (max-width: 783px) {
- .edit-php.post-type-popup .wrap .nav-tab-wrapper .page-title-action, .edit-php.post-type-popup_theme .wrap .nav-tab-wrapper .page-title-action, .popup_page_pum-extensions .wrap .nav-tab-wrapper .page-title-action {
- display: none !important
- }
- }
- </style>
- <nav class="nav-tab-wrapper">
- <?php
- $tabs = array(
- 'popups' => array(
- 'name' => esc_html( $popup_labels['name'] ),
- 'url' => admin_url( 'edit.php?post_type=popup' ),
- ),
- 'themes' => array(
- 'name' => esc_html( $theme_labels['name'] ),
- 'url' => admin_url( 'edit.php?post_type=popup_theme' ),
- ),
- 'integrations' => array(
- 'name' => esc_html__( 'Upgrade', 'popup-maker' ),
- 'url' => admin_url( 'edit.php?post_type=popup&page=pum-extensions&view=integrations' ),
- ),
- );
- $tabs = apply_filters( 'pum_add_ons_tabs', $tabs );
- $active_tab = false;
- // Calculate which tab is currently active.
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'pum-extensions' ) {
- $active_tab = 'integrations';
- } elseif ( ! isset( $_GET['page'] ) && isset( $_GET['post_type'] ) ) {
- switch ( $_GET['post_type'] ) {
- case 'popup':
- $active_tab = 'popups';
- break;
- case 'popup_theme':
- $active_tab = 'themes';
- break;
- }
- }
- // Add each tab, marking the current one as active.
- foreach ( $tabs as $tab_id => $tab ) {
- $active = $active_tab === $tab_id ? ' nav-tab-active' : '';
- ?>
- <a href="<?php echo esc_url( $tab['url'] ); ?>" class="nav-tab<?php echo esc_attr( $active ); ?>">
- <?php echo $tab['name']; ?>
- </a>
- <?php
- }
- ?>
- <a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=popup' ) ); ?>" class="page-title-action">
- <?php echo esc_html( $popup_labels['add_new_item'] ); ?>
- </a>
- <a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=popup_theme' ) ); ?>" class="page-title-action">
- <?php echo esc_html( $theme_labels['add_new_item'] ); ?>
- </a>
- </nav>
- <?php
- }
- }
|