settings(); add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); add_action( 'init', array( &$this, 'init' ), 10 ); add_action( 'wp_enqueue_scripts', array( &$this, 'init_scripts' ) ); add_action( 'admin_enqueue_scripts',array( &$this, 'admin_scripts' ) ); add_filter( 'plugin_action_links', array( &$this, 'settings_link' ), 10, 2); register_uninstall_hook( __FILE__, array( 'AspexiSweetPopups', 'uninstall' ) ); } /* WP init action */ public function init() { /* Internationalization */ load_plugin_textdomain( 'aspexisweetpopups', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } public function admin_menu() { add_submenu_page( 'themes.php', __( 'Aspexi Sweet Popups', 'aspexisweetpopups' ), __( 'Aspexi Sweet Popups', 'aspexisweetpopups' ), 'manage_options', basename(__FILE__), array( &$this, 'admin_page' ) ); } public function settings() { $config_default = array( 'aspexisweetpopups_version' => ASPEXISWEETPOPUPS_VERSION, 'status' => 'disabled', 'only_frontpage' => 'off', 'title' => 'Your title', 'content' => 'Your content', 'only_once' => 'off', 'only_once_days' => 30, 'icon_type' => 'empty', ); if ( ! get_option( 'aspexisweetpopups_options' ) ) add_option( 'aspexisweetpopups_options', $config_default, '', 'yes' ); $this->config = get_option( 'aspexisweetpopups_options' ); } public function get_content_with_shortcodes() { $content = nl2br( $this->config['content'] ); $matches = array(); preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches ); if ( ! empty( $matches[2] ) ) foreach ( $matches[2] as $key => $shortcode ) $content = str_replace( $matches[0][$key], do_shortcode( $matches[0][$key] ), $content ); return $content; } public function init_scripts() { $disable_maybe = apply_filters( 'aspexisweetpopups_disablemaybe', false ); if( $this->config['status'] != 'enabled' || ( $this->config['only_frontpage'] == 'on' && ! is_front_page() ) || $disable_maybe ) return; wp_enqueue_style( 'sweet-alert', ASPEXISWEETPOPUPS_URL . 'css/sweetalert.css' ); wp_enqueue_script( 'sweet-alert', ASPEXISWEETPOPUPS_URL . 'js/sweetalert.min.js' ); wp_enqueue_script( 'aspexi-sweet-popups', ASPEXISWEETPOPUPS_URL . 'js/asp.js', array( 'sweet-alert', 'jquery') ); wp_localize_script( 'aspexi-sweet-popups', 'asp', array( 'show' => ( isset( $_COOKIE[$this->cookie_name] ) && 'on' == $this->config['only_once'] ) ? false : true, 'title' => $this->config['title'], 'content' => $this->get_content_with_shortcodes(), 'icon_type' => $this->config['icon_type'], 'html' => 'true' ) ); $_expire = 0; if ( $this->config['only_once_days'] != '' ) $_expire = absint( (int)$this->config['only_once_days'] ); if( ! isset( $_COOKIE[$this->cookie_name] ) && 'on' == $this->config['only_once'] ) { if( 0 == $_expire ) $expire = 0; else $expire = time() + ( 60 * 60 * 24 * $_expire ); setcookie( $this->cookie_name, 'false', $expire ); } elseif( isset( $_COOKIE[$this->cookie_name] ) && 'on' != $this->config['only_once'] ) // remove cookie setcookie( $this->cookie_name, '', time() - 360 ); } public function admin_scripts( $hook_suffix ) { if( 'appearance_page_'.basename(__FILE__, '.php') != $hook_suffix ) return; wp_enqueue_style( 'sweet-alert', ASPEXISWEETPOPUPS_URL . 'css/sweetalert.css' ); wp_enqueue_style( 'sweet-popups', ASPEXISWEETPOPUPS_URL . 'css/sweet-popups.css' ); wp_enqueue_script( 'sweet-alert', ASPEXISWEETPOPUPS_URL . 'js/sweetalert.min.js' ); wp_enqueue_script( 'aspexi-sweet-popups', ASPEXISWEETPOPUPS_URL . 'js/asp-admin.js', array( 'sweet-alert', 'jquery') ); wp_localize_script( 'aspexi-sweet-popups', 'asp', array( 'show' => ( isset( $_COOKIE[$this->cookie_name] ) && 'on' == $this->config['only_once'] ) ? false : true, 'title' => $this->config['title'], 'content' => nl2br( $this->config['content'] ), 'icon_type' => $this->config['icon_type'], 'html' => 'true', 'aspexisweetpopups_url' => ASPEXISWEETPOPUPS_URL, 'nav_tab_changed_title' => __( 'Unsaved changes!', 'aspexisweetpopups' ), 'nav_tab_changed_text' => __( 'If you leave this page now the changes you have made may be lost.', 'aspexisweetpopups' ), 'nav_tab_changed_yes' => __( 'Stay and continue', 'aspexisweetpopups' ), 'nav_tab_changed_no' => __( 'Drop changes and leave', 'aspexisweetpopups' ), ) ); } public function get_pro_url() { return 'http://aspexi.com/downloads/aspexi-sweet-popups/?src=free_plugin'; } public function get_pro_link() { return ''.__( 'Get PRO version', 'aspexisweetpopups' ).''; } public function settings_link( $action_links, $plugin_file ) { if( $plugin_file == plugin_basename(__FILE__) ) { $pro_link = $this->get_pro_link(); array_unshift( $action_links, $pro_link ); $settings_link = '' . __("Settings") . ''; array_unshift( $action_links, $settings_link ); } return $action_links; } public static function uninstall() { delete_option( 'aspexisweetpopups_options' ); } public function display_admin_notices( $echo = false ) { $ret = ''; foreach( (array)$this->errors as $error ) $ret .= '

'.$error.'

'; foreach( (array)$this->messages as $message ) $ret .= '

'.$message.'

'; if( $echo ) echo $ret; else return $ret; } public function admin_page() { if ( ! current_user_can('manage_options') ) wp_die( __('You do not have sufficient permissions to access this page.') ); if ( isset( $_REQUEST['asp_form_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'asp_nonce_name' ) ) { if ( ! in_array( $_REQUEST['asp_status'], array( 'enabled', 'disabled' ) ) ) $this->add_error( __( 'Wrong or missing status. Available statuses: enabled and disabled. Settings not saved.' ) ); if ( ! in_array( $_REQUEST['asp_icon_type'], array( 'empty', 'warning', 'error', 'success', 'info' ) ) ) $this->add_error( __( 'Wrong icon type. Available types: empty, warning, error, success, info. Settings not saved.' ) ); if( isset( $_REQUEST['asp_content'] ) ) { $_asp_content = stripslashes( wp_kses_post( balanceTags( $_REQUEST['asp_content'], true ) ) ); if( ! strlen( $_asp_content ) ) $this->add_error( __( 'Missing Popup content. Settings not saved.') ); } else $this->add_error( __( 'Missing Popup content. Settings not saved.') ); if ( ! $this->has_errors() ) { $aspexisweetpopups_request_options = array(); $aspexisweetpopups_request_options['status'] = isset( $_REQUEST['asp_status'] ) ? sanitize_text_field( $_REQUEST['asp_status'] ) : ''; $aspexisweetpopups_request_options['only_frontpage'] = isset( $_REQUEST['asp_only_frontpage'] ) ? sanitize_text_field( $_REQUEST['asp_only_frontpage'] ) : ''; $aspexisweetpopups_request_options['title'] = isset( $_REQUEST['asp_title'] ) ? sanitize_text_field( $_REQUEST['asp_title'] ) : ''; $aspexisweetpopups_request_options['content'] = $_asp_content; $aspexisweetpopups_request_options['only_once'] = isset( $_REQUEST['asp_only_once'] ) ? sanitize_text_field( $_REQUEST['asp_only_once'] ) : ''; if( 'on' == $aspexisweetpopups_request_options['only_once'] ) $aspexisweetpopups_request_options['only_once_days'] = isset( $_REQUEST['asp_only_once_days'] ) ? absint( (int) $_REQUEST['asp_only_once_days'] ) : ''; $aspexisweetpopups_request_options['icon_type'] = isset( $_REQUEST['asp_icon_type'] ) ? sanitize_text_field( $_REQUEST['asp_icon_type'] ) : ''; $this->config = array_merge( $this->config, $aspexisweetpopups_request_options ); update_option( 'aspexisweetpopups_options', $this->config, 'yes' ); $this->add_message( __( 'Settings saved.', 'aspexisweetpopups' ) ); } } ?>
display_admin_notices( true ); ?>


Shortcode

get_pro_link(); ?>

[aspexi_sweet_popups theme="facebook" close_button_button="on" close_button_icon="on" close_button_color="#8cd4f5" like_box="on" like_box_protocol="http" like_box_option_url="any" like_box_url="www.facebook.com/facebook" like_box_layout="box_count" only_home="on" only_bottom="on" auto_open="on" auto_open_time="3000" auto_open_on_element="off" auto_open_on_element_name="#element_name" title="Your Title" only_once="on" only_once_days="30" icon_type="success"]Your Content[/aspexi_sweet_popups]



:
  • theme: none|facebook|google|twitter
  • close_button_button: on|off (Default: on)
  • close_button_icon: on|off (Default: off)
  • close_button_color: (css color) (Default: #8cd4f58cd4f5)
  • like_box: on|off (Default: off)
  • like_box_protocol: http|https (Default: http)
  • like_box_option_url: any|site|page (Default: any)
  • like_box_url: (url, for example: www.facebook.com/facebook) (Default: empty)
  • like_box_layout: standard|box_count|button_count|button (Default: standard)
  • only_home: on|off (Default: off)
  • only_bottom: on|off (Default: off)
  • auto_open: on|off (Default: off)
  • auto_open_time: (time in milliseconds) (Default: 3000)
  • auto_open_on_element: on|off (Default: off)
  • auto_open_on_element_name: (jQuery element, for example #element_name) (Default: empty)
  • title: (text) (Default empty)
  • only_once: on|off (Default: off)
  • only_once_days: (Show only once per user (based on cookies)) (Default: 1)
  • icon_type: empty|info|warning|success|error (Default: empty)

:

[aspexi_sweet_popups]Your Content[/aspexi_sweet_popups]



:

[aspexi_sweet_popups close_button_button="off" close_button_icon="on" title="custom title"]Your Content[/aspexi_sweet_popups]



:

[aspexi_sweet_popups theme="facebook" close_button_button="on" close_button_icon="on" like_box="on" like_box_protocol="http" like_box_url="www.facebook.com/facebook" like_box_layout="standard" auto_open="on" auto_open_time="3000" title="Your Title" icon_type="info" ]Your Content[/aspexi_sweet_popups]



get_pro_link(); ?>

get_pro_link(); ?>

get_pro_link(); ?>
[aspexi_newsletter]

get_pro_link(); ?>


get_pro_link(); ?>

get_pro_link(); ?>

get_pro_link(); ?>

config['only_frontpage'] == 'on') ? 'checked' : ''; ?>>

get_pro_link(); ?>

config['only_once'] ) ? 'checked' : ''; ?> value="on">
config['only_once'] ) ? 'disabled' : ''; ?>>  



Facebook


Google


Twitter

get_pro_link(); ?>














get_pro_link(); ?>

Facebook


get_pro_link(); ?>
get_pro_link(); ?>
get_pro_link(); ?>


standard


box_count


button_count


button


  
get_pro_link(); ?>

   
get_pro_link(); ?>

config['autoopenonposition'] ) echo 'readonly'; ?> size="5" value="config['autoopenonposition_px']; ?>">px from:
get_pro_link(); ?>


Made by

messages[] = $message; } public function has_errors() { return count( $this->errors ); } private function add_error( $error ) { $error = trim( $error ); if( strlen( $error ) ) $this->errors[] = $error; } } global $aspexi_sweet_popups; $aspexi_sweet_popups = new AspexiSweetPopups(); }