null,
'dashboard_widget' => 30
);
private $two_step_ids_on_page = array();
public function __construct( $settings ) {
$this->settings = $settings;
$providers_available = array_keys( $this->settings[ 'providers' ] );
// Register custom post type
add_action( 'init', array( $this, 'register_custom_post_type' ) );
add_filter( 'manage_easy-opt-ins_posts_columns', array( $this, 'add_new_columns' ) );
add_action( 'manage_easy-opt-ins_posts_custom_column', array( $this, 'set_column_data' ), 10, 2 );
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
// Reset action
add_action( 'admin_post_fca_eoi_reset_stats', array( $this, 'reset_stats' ) );
// Dashboard widget
add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) );
// Save
add_action( 'save_post', array( $this, 'save_meta_box_content' ), 1, 2 );
// Live preview
add_filter( 'the_content', array( $this, 'live_preview' ) );
// Scripts and styles
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
add_action( 'admin_head', array( $this, 'hide_minor_publishing' ) );
add_action( 'admin_notices', array( $this, 'onboard_help' ), 1 );
if ( $this->settings['distribution'] === 'free' ) {
add_action( 'admin_notices', array( $this, 'review_notice' ) );
}
//V 2.0 BLOG POST NOTICE
add_action( 'admin_notices', array( $this, 'google_changes_notice' ) );
add_filter( 'admin_body_class', array( $this, 'add_body_class' ) );
add_filter( 'wp_insert_post_data', array( $this, 'force_published' ) );
add_action( 'wp_ajax_fca_eoi_subscribe', array( $this, 'ajax_subscribe' ) );
add_action( 'wp_ajax_nopriv_fca_eoi_subscribe', array( $this, 'ajax_subscribe' ) );
add_action( 'wp_ajax_fca_eoi_dismiss', array( $this, 'ajax_dismiss_notice' ) );
add_filter( 'get_user_option_screen_layout_easy-opt-ins', array( $this, 'force_one_column' ) );
add_filter( 'get_user_option_meta-box-order_easy-opt-ins', array( $this, 'order_columns' ) );
add_filter( 'post_updated_messages', array( $this, 'override_text' ) );
add_filter( 'bulk_actions-edit-easy-opt-ins', array( $this, 'disable_bulk_edit' ) );
add_filter( 'post_row_actions', array( $this, 'remove_quick_edit' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_filter( 'enter_title_here', array( $this, 'change_default_title' ) );
add_filter( 'init', array( $this, 'bind_content_filter' ), 10 );
add_filter( 'plugin_action_links_' . FCA_EOI_PLUGIN_BASENAME, array( $this, 'add_plugin_action_links' ) );
//ADD ACTIONS TO GET THE ENTIRE PAGE OUTPUT IN BUFFER
if ( wp_get_theme() == 'Customizr' ) {
add_filter( 'the_content', array( $this, 'scan_for_shortcodes' ) );
} else {
add_action('wp_head', array( $this, 'fca_eoi_buffer_start' ));
add_action('wp_footer', array( $this, 'fca_eoi_buffer_end' ));
}
add_filter( 'wp_footer', array( $this, 'maybe_show_lightbox' ) );
foreach ( $providers_available as $provider ) {
add_action( 'wp_ajax_fca_eoi_' . $provider . '_get_lists', $provider . '_ajax_get_lists' );
}
// Hook provder callback functions
foreach ( $providers_available as $provider ) {
add_filter( 'fca_eoi_alter_admin_notices', $provider . '_admin_notices', 10, 1 );
}
// Handle licensing
if( count( $providers_available ) > 1 ) {
require_once FCA_EOI_PLUGIN_DIR . 'includes/licensing.php';
new EasyOptInsLicense( $this->settings );
}
}
public function add_plugin_action_links( $links ) {
$url = admin_url('post-new.php?post_type=easy-opt-ins');
$new_links = array(
'addnew' => "" . __('Add New Optin Form', 'easy-opt-ins' ) . ''
);
$links = array_merge( $new_links, $links );
return $links;
}
function fca_eoi_buffer_start() { ob_start(array( $this, 'scan_for_shortcodes' )); }
function fca_eoi_buffer_end() { ob_end_flush(); }
public function register_custom_post_type() {
$labels = array(
'name' => __('Optin Forms') ,
'singular_name' => __('Optin Form') ,
'add_new' => __('Add New') ,
'add_new_item' => __('Add New Optin Form') ,
'edit_item' => __('Edit Optin Form') ,
'new_item' => __('New Optin Form') ,
'all_items' => __('All Optin Forms') ,
'view_item' => __('View Optin Form') ,
'search_items' => __('Search Optin Form') ,
'not_found' => __('No Optin Form Found') ,
'not_found_in_trash' => __('No Optin Form Found in Trash') ,
'parent_item_colon' => '',
'menu_name' => __('Optin Forms')
);
$args = array(
'menu_icon' => FCA_EOI_PLUGIN_URL . '/icon.png',
'labels' => $labels,
'public' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'easy-opt-ins',
) ,
'capability_type' => 'page',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 105,
'supports' => array(
'title',
) ,
'register_meta_box_cb' => array(
$this,
'add_meta_boxes'
)
);
register_post_type('easy-opt-ins', $args);
}
private function enqueue_activity_style() {
wp_enqueue_style( 'admin-cpt-easy-opt-ins-activity', FCA_EOI_PLUGIN_URL . '/assets/admin/cpt-easy-opt-ins-activity.min.css', array(), FCA_EOI_VER );
}
public function add_new_columns( $columns ) {
$new_columns = array();
if ( ! empty( $columns['cb'] ) ) {
$new_columns['cb'] = $columns['cb'];
}
if ( ! empty( $columns['title'] ) ) {
$new_columns['title'] = $columns['title'];
}
$this->enqueue_activity_style();
$activity = EasyOptInsActivity::get_instance();
$period =
'(' .
$activity->get_text( 'period', null, array( $this->activity_day_interval['form_list'] ) ) .
')';
foreach ( array( 'impressions', 'conversions', 'conversion_rate' ) as $activity_type ) {
$new_columns[ $activity_type ] = esc_html( $activity->get_text( $activity_type, 'form' ) ) . '
' . $period;
}
return $new_columns;
}
public function set_column_data( $column_name, $form_id ) {
$activity = EasyOptInsActivity::get_instance();
$stats = $activity->get_form_stats( $this->activity_day_interval['form_list'] );
$value = 0;
if ( ! empty( $stats[ $column_name ][ $form_id ] ) ) {
$value = $stats[ $column_name ][ $form_id ];
}
echo $activity->format_column_text( $column_name, $value );
}
public function post_row_actions( $actions, $post ) {
if ( $post->post_type == 'easy-opt-ins' ) {
$action = 'fca_eoi_reset_stats';
$title = __( 'Reset stats for this item' );
$label = __( 'Reset Stats' );
$url = add_query_arg( 'action', $action, admin_url( 'admin-post.php?post=' . $post->ID ) );
$url = wp_nonce_url( $url );
$actions[$action] = $this->confirm_tag(
'' . $label . '',
__( 'Are you sure?' ),
__( 'Do you really want to reset this Optin Form\'s stats? This action cannot be undone.' )
);
}
return $actions;
}
public function reset_stats() {
if ( wp_verify_nonce( $_REQUEST['_wpnonce'] ) ) {
EasyOptInsActivity::get_instance()->reset_stats( (int) $_REQUEST['post'] );
wp_redirect( wp_get_referer() );
}
}
private function confirm_tag( $tag, $title, $message ) {
return preg_replace(
'/>/',
' onclick="return confirm(' .
esc_html( '"' . $title . '\n\n' . $message . '"' ) .
')">',
$tag, 1 );
}
public function dashboard_setup() {
if ( defined ( 'FCA_EOI_DISABLE_STATS_TRACKING' )) {
$title = 'Optin Cat Summary (TRACKING DISABLED)';
} else {
$title = 'Optin Cat Summary';
}
add_meta_box(
'fca_eoi_dashboard_widget',
$title,
array( $this, 'add_dashboard_widget' ),
'dashboard',
'normal',
'high'
);
}
public function add_dashboard_widget() {
wp_enqueue_script( 'd3_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/nvd3/d3.min.js', array(), FCA_EOI_VER, true );
wp_enqueue_script( 'nvd3_js', FCA_EOI_PLUGIN_URL . '/assets/vendor/nvd3/nv.d3.min.js', array(), FCA_EOI_VER, true );
wp_enqueue_style( 'nvd3_css', FCA_EOI_PLUGIN_URL . '/assets/vendor/nvd3/nv.d3.min.css', array(), FCA_EOI_VER );
$this->enqueue_activity_style();
$day_interval = $this->activity_day_interval['dashboard_widget'];
$activity = EasyOptInsActivity::get_instance();
$stats = $activity->get_daily_stats( $day_interval );
$date_labels = array();
foreach ( array_keys( $stats['impressions'] ) as $date ) {
$date_labels[] = strftime( '%e %b', strtotime( $date ) );
}
$colors = array(
'impressions' => '#5b90bf',
'conversions' => '#bf616a'
);
?>
:input
', ) ); K::wrap( __( 'Append to post or page'), array( 'style' => 'padding-left: 0px; padding-right: 0px; ' ), array( 'in' => 'h3' ) ); K::wrap( __( 'Automatically append this optin to the following posts, categories and/or pages.' ), null, array( 'in' => 'p' ) ); k_selector( 'fca_eoi[publish_postbox]', K::get_var( 'publish_postbox', $fca_eoi, array() ) ); echo '| Display Frequency" . fca_eoi_tooltip ( __('Set the minimum time between visits your optin will display to each user', 'easy-opt-ins') ) . " | "; K::select( 'fca_eoi[publish_lightbox][show_every]', array(), array( 'options' => array( 'always' => __( 'On every pageview' ), 'session' => __( 'Once per visit' ), 'day' => __( 'Once per day' ), 'month' => __( 'Once per month' ), 'once' => __( 'Only once' ), ), 'selected' => K::get_var( 'show_every', $fca_eoi[ 'publish_lightbox' ], 'month' ), ) ); echo " |
|---|---|
| Devices to Display on | "; K::select( 'fca_eoi[publish_lightbox][devices]', array(), array( 'options' => array( 'desktop' => __( 'Desktop Only' ), 'mobile' => __( 'Mobile Only' ), 'all' => __( 'Desktop & Mobile' ), ), 'selected' => K::get_var( 'devices', $fca_eoi[ 'publish_lightbox' ], 'all' ), ) ); echo " |
| Success Cookie Duration" . fca_eoi_tooltip ( __('The number of days before the optin will display again once the user successfully opts in to your campaign.', 'easy-opt-ins') ) . " | "; K::input( 'fca_eoi[publish_lightbox][success_duration]', array( 'type' => 'number', 'class' => 'regular-text', 'min' => 0, 'value' => K::get_var( 'success_duration', $fca_eoi[ 'publish_lightbox' ], 365 ), ) ); echo " days |
| Deployed (makes this optin go live) | "; K::input( 'fca_eoi[publish_lightbox][live]', array( 'type' => 'checkbox', 'checked' => K::get_var( 'live', $fca_eoi[ 'publish_lightbox' ], '' ), 'class' => 'switch-input' ), array( 'format' => '' ) ); echo " |
|---|
Placement
Push Page Down
:inputpx
Headline Field
Description Field
Name Field
After Button Area
Optin Cat Branding
:input
:input
';
echo '
';
echo '
';
echo '' . __( "Optin Cat: New Google algorithm update may affect your rankings", 'easy-opt-ins' ) . '
'; echo '' . __( "Google has recently made changes to its mobile search results. These changes may negatively impact sites that use popups on mobile devices if no action is taken.", 'easy-opt-ins') . '
'; echo '
';
echo '' . __( "Great work! You've gotten more than 25 email subscribers using Optin Cat.", 'easy-opt-ins' ) . '
'; echo '' . sprintf( __( "If you love Optin Cat, why not leave us a nice review on %sWordPress.org%s? Reviews keeps us motivated - we'd really appreciate it.", 'easy-opt-ins' ), "", '') . '
'; echo '' . $error . '