$module) { // Filter to add Opt In / Out row add_filter( 'plugin_action_links_' . $module_key, array($this, 'wpos_anylc_add_action_links'), 10, 4 ); } } // Action to remove admin menu add_action( 'admin_menu', array($this, 'wpos_anylc_remove_admin_menu'), 999 ); // Action to add admin menu add_action( 'admin_menu', array($this, 'wpos_anylc_register_admin_menu'), 15 ); // Action to redirect plugin / theme on activation add_action( 'admin_init', array($this, 'wpos_anylc_admin_init_process') ); // Action to show optin notice add_action( 'admin_notices', array($this, 'wpos_anylc_optin_notice') ); // Action to add Attachment Popup HTML add_action( 'admin_footer', array($this,'wpos_anylc_optout_popup') ); // Action to perform analytic action add_action( 'wp_loaded', array($this, 'wpos_anylc_action_process') ); } /** * Remove admin menus * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_remove_admin_menu() { global $menu, $submenu, $wpos_analytics_module; if( !empty( $wpos_analytics_module ) ) { foreach ($wpos_analytics_module as $module_key => $module) { $opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] ); if( !empty( $module['menu'] ) && !isset( $opt_in_data['status'] ) ) { remove_menu_page( $module['menu'] ); } } } } /** * Add menu * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_register_admin_menu() { global $menu, $submenu, $wpos_analytics_module; if( !empty( $wpos_analytics_module ) ) { // WP Menu data $wpos_menu_data = wp_list_pluck( $menu, 2 ); $anylc_page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : null; foreach ($wpos_analytics_module as $module_key => $module) { $opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] ); $optin_status = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null; // Offers Page if( !empty( $module['offers'] ) && $anylc_page == $module['slug'].'-offers' ) { add_submenu_page( $module['menu'], 'WPOS Offers', 'Premium Offers', 'manage_options', $module['slug'].'-offers', array($this, 'wpos_anylc_offers_html') ); } // If data is set if( $optin_status == 1 ) { continue; } // Taking some variables $menu_args = array(); if( $optin_status === 0 || $optin_status === 2 ) { // Register admin menu if( $anylc_page == $module['slug'] ) { add_submenu_page( $module['menu'], $module['name'].' '.'Opt In', $module['name'].' '.'Opt In', 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html') ); } } else { if( !empty( $wpos_menu_data ) ) { $orig_menu_pos = array_search( $module['menu'], $wpos_menu_data ); if( $orig_menu_pos !== false ) { $menu_args = array( 'name' => $menu[ $orig_menu_pos ][0], 'icon' => $menu[ $orig_menu_pos ][6], 'position' => $orig_menu_pos, ); } } // Taking default name and icon if( empty( $menu_args ) ) { $menu_args = array( 'name' => $module['name'], 'icon' => false, 'position' => null, ); } // Register admin menu add_menu_page( $menu_args['name'], $menu_args['name'], 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html'), $menu_args['icon'], $menu_args['position'] ); } } // End of for each } } /** * Display Opt in form HTML * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_page_html() { global $current_user, $wpos_analytics_product; $anylc_product_name = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; // if no data is set then return if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) { return; } // Taking soem data $optin_form_data = wpos_anylc_optin_data(); $analy_product = $wpos_analytics_product[ $anylc_product_name ]; $opt_in_data = wpos_anylc_get_option( $analy_product['anylc_optin'] ); $opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null; $user_name = !empty( $current_user->first_name ) ? $current_user->first_name : ''; $user_name = empty( $user_name ) ? $current_user->nickname : $user_name; $product_name = $analy_product['name']; $skip_url = add_query_arg( array( 'page' => $anylc_product_name, 'wpos_anylc_action' => 'skip'), admin_url('admin.php') ); $skip_url = wp_nonce_url( $skip_url, 'wpos_anylc_act' ); require_once WPOS_ANYLC_DIR .'/templates/analytic.php'; } /** * Display Offers HTML * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_offers_html() { global $wpos_analytics_product; $anylc_product_name = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; $anylc_product_name = str_replace( '-offers', '', $anylc_product_name ); // if no data is set then return if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) { return; } // Taking soem data $analy_product = $wpos_analytics_product[ $anylc_product_name ]; $opt_in_data = wpos_anylc_get_option( $analy_product['anylc_optin'] ); $opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null; include_once( WPOS_ANYLC_DIR .'/templates/offers.php' ); } /** * Add Action links * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_add_action_links( $actions, $plugin_file, $plugin_data, $context ) { global $wpos_analytics_module; // Taking some data $module_data = !empty( $wpos_analytics_module[ $plugin_file ] ) ? $wpos_analytics_module[ $plugin_file ] : ''; // If analytics module data is there if( $module_data ) { $opt_in_data = wpos_anylc_get_option( $module_data['anylc_optin'] ); $opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1; // If user has opt in if( $opt_in == 1 ) { $new_links['wpos_anylc'] = ''.__('Opt Out', 'wpos_analytic').''; } else { $opt_in_link = wpos_anylc_optin_url( $module_data, $opt_in ); $new_links['wpos_anylc'] = ''.__('Opt In', 'wpos_analytic').''; } $actions = array_merge( $new_links, $actions ); } return $actions; } /** * Redirect plugin / theme on activation to its opt in menu * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_admin_init_process() { // If license notice is dismissed if( isset($_GET['message']) && $_GET['message'] == 'wpos-anylc-dismiss-notice' && !empty( $_GET['anylc_id'] ) ) { $anylc_id = sanitize_text_field( $_GET['anylc_id'] ); set_transient( 'wpos_anylc_optin_notice_'.$anylc_id, true, 172800 ); } $redirect = get_option('wpos_anylc_redirect'); // return if no activation redirect if ( ! $redirect ) { return; } // Flush the redirect transient update_option( 'wpos_anylc_redirect', '' ); // Redirect to about page wp_safe_redirect( $redirect ); exit; } /** * Display Analytic Optin notice * * @package Wpos Analytic * @since 1.0 */ function wpos_anylc_optin_notice() { global $current_screen, $wpos_analytics_module, $wpos_analytics_product; // Taking some variables $screen_id = isset( $current_screen->id ) ? $current_screen->id : ''; // Plugin action links if( $screen_id == 'dashboard' && current_user_can('manage_options') && !empty( $wpos_analytics_module ) ) { foreach ($wpos_analytics_module as $module_key => $module) { $anylc_pdt_id = $module['id']; $notice_transient = get_transient( 'wpos_anylc_optin_notice_'.$anylc_pdt_id ); if( $notice_transient == false ) { $opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] ); $opt_in = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1; $notice_link = add_query_arg( array('message' => 'wpos-anylc-dismiss-notice', 'anylc_id' => $anylc_pdt_id), admin_url('index.php') ); // If user has opt in if( $opt_in == -1 ) { $anylc_pdt_name = $module['name']; $anylc_optin_url = wpos_anylc_optin_url( $module, $opt_in ); echo '
'.$anylc_pdt_name.' - We made a few tweaks to the plugin, Opt in to make it Better!
Sorry to let you go. You are now opted out from the plugin.
Your Download has been started. In case if it is intrupted then download it from here. '.join(' | ', $promotion_pdt_data).'