Ejemplo n.º 1
0
function snp_setup_admin()
{
    $args = array();
    $args['dev_mode'] = false;
    $args['intro_text'] = __('<p></p>', 'nhp-opts');
    $args['share_icons']['facebook'] = array('link' => 'https://www.facebook.com/arscode', 'title' => 'Find us on Facebook', 'img' => SNP_NHP_OPTIONS_URL . 'img/glyphicons/glyphicons_320_facebook.png');
    $args['show_import_export'] = false;
    $args['opt_name'] = SNP_OPTIONS;
    $args['page_type'] = 'submenu';
    $args['page_parent'] = 'edit.php?post_type=snp_popups';
    $args['menu_title'] = __('Settings', 'nhp-opts');
    $args['page_title'] = __('Ninja Popups', 'nhp-opts');
    $args['page_slug'] = 'snp_opt';
    snp_init();
    //add_submenu_page( 'admin.php?page=snp_opt', 'Preview', 'Preview', 'manage_options', 'snp_preview', 'snp_page_preview' );
    add_filter("mce_external_plugins", "snp_register_tinymce_plugin");
    add_filter('mce_buttons', 'snp_add_tinymce_button');
    add_filter('manage_edit-snp_popups_columns', 'snp_add_columns');
    add_filter('manage_edit-snp_ab_columns', 'snp_ab_add_columns');
    add_action('manage_snp_popups_posts_custom_column', 'snp_manage_columns', 10, 2);
    add_action('manage_snp_ab_posts_custom_column', 'snp_manage_columns', 10, 2);
    if (!snp_get_option('disable_np_columns')) {
        add_filter('manage_edit-post_columns', 'snp_add_columns_posts');
        add_filter('manage_edit-page_columns', 'snp_add_columns_posts');
        add_filter('manage_edit-product_columns', 'snp_add_columns_posts');
        //add_filter('manage_edit-category_columns', 'snp_add_columns_posts');
        //add_filter('manage_edit-product_cat_columns', 'snp_add_columns_posts');
        add_action('manage_posts_custom_column', 'snp_manage_columns_posts_post', 10, 2);
        add_action('manage_page_posts_custom_column', 'snp_manage_columns_posts_post', 10, 2);
        add_action('manage_product_custom_column', 'snp_manage_columns_posts_post', 10, 2);
        //add_action('manage_category_custom_column', 'snp_manage_columns_posts_term', 10, 3);
        //add_action('manage_product_cat_custom_column', 'snp_manage_columns_posts_term', 10, 3);
        $enable_taxs = snp_get_option('enable_taxs');
        if (is_array($enable_taxs)) {
            foreach ((array) $enable_taxs as $k => $v) {
                add_filter('manage_edit-' . $k . '_columns', 'snp_add_columns_posts');
                add_action('manage_' . $k . '_custom_column', 'snp_manage_columns_posts_term', 10, 3);
            }
        }
    }
    add_action('wp_ajax_snp_preview_popup', 'snp_preview_popup');
    add_action('wp_ajax_snp_insert_shortcode', 'snp_ajax_insert_shortcode');
    add_action('wp_ajax_snp_ml_list', 'snp_ml_list');
    add_action('wp_ajax_snp_popup_fields', 'snp_popup_fields');
    add_action('wp_ajax_snp_popup_colors', 'snp_popup_colors');
    add_action('wp_ajax_snp_popup_types', 'snp_popup_types');
    add_action('wp_ajax_snp_disable_affiliate_message', 'snp_ajax_disable_affiliate_message');
    add_action('wp_ajax_snp_dismiss_update_message', 'snp_ajax_dismiss_update_message');
    add_action('wp_ajax_snp_purchasecode_check', 'snp_ajax_purchasecode_check');
    add_action('admin_head-post-new.php', 'snp_posttype_admin_css');
    add_action('admin_head-post.php', 'snp_posttype_admin_css');
    add_action('admin_head-edit.php', 'snp_posttype_admin_css');
    $Popups = snp_get_popups();
    $ABTesting = snp_get_ab();
    $customfields[] = array('id' => 'snp-cf-gsp', 'post_type' => array('snp_ab'), 'title' => __('Popups', 'nhp-opts'), 'fields' => array(array('id' => 'forms', 'type' => 'multi_checkbox', 'title' => __('Select', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'options' => $Popups)));
    $Popups = (array) $Popups + (array) $ABTesting;
    $Popups['disabled'] = 'Disabled';
    $sections = array();
    global $FB_Locales;
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_gen_settings.png', 'title' => __('General Settings', 'nhp-opts'), 'fields' => array(array('id' => 'enable', 'type' => 'select', 'title' => __('Enable Plugin', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'enabled', 'options' => array('enabled' => 'Enabled', 'disabled' => 'Disabled')), array('id' => 'enable_mobile', 'type' => 'select', 'title' => __('Enable Plugin on Mobile Devices', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'enabled', 'options' => array('enabled' => 'Enabled', 'disabled' => 'Disabled')), array('id' => 'enable_analytics_events', 'type' => 'select', 'title' => __('Enable Google Analytics Event Tracking', 'nhp-opts'), 'desc' => __('<b>Google Universal Analytics</b> should be installed on the site.', 'nhp-opts'), 'std' => 'no', 'options' => array('no' => 'No', 'yes' => 'Yes'))));
    $sections_welcome = array(array('id' => 'welcome_popup', 'type' => 'select', 'title' => __('Default Welcome Popup', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'disabled', 'options' => $Popups));
    $sections_exit = array(array('id' => 'exit_popup', 'type' => 'select', 'title' => __('Default Exit Popup', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'disabled', 'options' => $Popups));
    if (function_exists('icl_get_languages')) {
        $Popups['global'] = 'Use global settings';
        $langs = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str');
        foreach ($langs as $language) {
            $sections_welcome[] = array('id' => 'welcome_popup_' . $language['language_code'], 'type' => 'select', 'title' => __('Default Welcome Popup [' . $language['native_name'] . ']', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'global', 'options' => $Popups);
            $sections_exit[] = array('id' => 'exit_popup_' . $language['language_code'], 'type' => 'select', 'title' => __('Default Exit Popup [' . $language['native_name'] . ']', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'global', 'options' => $Popups);
        }
    }
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_welcome_settings.png', 'title' => __('Welcome', 'nhp-opts'), 'fields' => array_merge($sections_welcome, array(array('id' => 'welcome_display_in', 'type' => 'multi_checkbox', 'title' => __('Display in:', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => array('home' => 1, 'pages' => 1, 'posts' => 1, 'others' => 1), 'options' => array('home' => 'Home', 'pages' => 'Pages', 'posts' => 'Posts', 'others' => 'Categories, Archive and other')), array('id' => 'welcome_disable_for_logged', 'type' => 'checkbox', 'title' => __('Disable for logged users', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''))));
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_exit_settings.png', 'title' => __('Exit', 'nhp-opts'), 'fields' => array_merge($sections_exit, array(array('id' => 'exit_display_in', 'type' => 'multi_checkbox', 'title' => __('Display in:', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => array('home' => 1, 'pages' => 1, 'posts' => 1, 'others' => 1), 'options' => array('home' => 'Home', 'pages' => 'Pages', 'posts' => 'Posts', 'others' => 'Categories, Archive and other')), array('id' => 'use_in', 'type' => 'multi_checkbox', 'title' => __('Use popup external for links in:', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => array('the_content' => 1, 'the_excerpt' => 1, 'widget_text' => 1, 'comment_text' => 1), 'options' => array('the_content' => 'Content', 'the_excerpt' => 'Excerpts', 'widget_text' => 'Widgets Text', 'comment_text' => 'Comments', 'all' => 'All links (Menu, sidebars, footer, etc.)')), array('id' => 'exit_excluded_urls', 'type' => 'multi_text', 'title' => __('Excluded URLs', 'nhp-opts'), 'desc' => __('Add external URLs for which you want to disable/skip exit popup.', 'nhp-opts')), array('id' => 'exit_disable_for_logged', 'type' => 'checkbox', 'title' => __('Disable for logged users', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''))));
    $ml_managers = array('0' => array('name' => '--'), 'email' => array('name' => 'Send Optins to E-mail', 'fieldsgroup' => 'fg_email'), 'aweber' => array('name' => 'AWeber', 'fieldsgroup' => 'fg_aweber'), 'mailchimp' => array('name' => 'MailChimp', 'fieldsgroup' => 'fg_mailchimp'), 'getresponse' => array('name' => 'GetResponse', 'fieldsgroup' => 'fg_getresponse'), 'campaignmonitor' => array('name' => 'CampaignMonitor', 'fieldsgroup' => 'fg_campaignmonitor'), 'icontact' => array('name' => 'iContact', 'fieldsgroup' => 'fg_icontact'), 'constantcontact' => array('name' => 'Constant Contact', 'fieldsgroup' => 'fg_constantcontact'), 'madmimi' => array('name' => 'Mad Mimi', 'fieldsgroup' => 'fg_madmimi'), 'infusionsoft' => array('name' => 'Infusionsoft', 'fieldsgroup' => 'fg_inf'), 'directmail' => array('name' => 'Direct Mail for OS X', 'fieldsgroup' => 'fg_directmail'), 'sendy' => array('name' => 'Sendy', 'fieldsgroup' => 'fg_sendy'), 'egoi' => array('name' => 'e-goi', 'fieldsgroup' => 'fg_egoi'), 'csv' => array('name' => 'Store in CSV File', 'fieldsgroup' => 'fg_csv'), 'html' => array('name' => 'HTML Form', 'fieldsgroup' => 'fg_html'));
    if (class_exists('WYSIJA')) {
        $ml_managers['wysija'] = array('name' => 'Wysija', 'fieldsgroup' => 'fg_wysija');
    }
    if (defined('MYMAIL_VERSION') && version_compare(MYMAIL_VERSION, '1.3.1.2') >= 0) {
        $ml_managers['mymail'] = array('name' => 'MyMail', 'fieldsgroup' => 'fg_mymail');
    }
    if (defined('SENDPRESS_VERSION')) {
        $ml_managers['sendpress'] = array('name' => 'SendPress', 'fieldsgroup' => 'fg_sendpress');
    }
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_ml_settings.png', 'title' => __('Mailing List Manager', 'nhp-opts'), 'fields' => array(array('id' => 'ml_manager', 'type' => 'select_show_fieldsgroup', 'title' => __('Mailing List Manager', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'email', 'options' => $ml_managers), array('id' => 'ml_aw_auth', 'type' => 'aweber_auth', 'class' => 'fg_ml_manager fg_aweber large-text', 'title' => __('AWeber Connection', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_aw_lists', 'type' => 'aweber_lists', 'class' => 'fg_ml_manager fg_aweber', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_htmlform_exp', 'type' => 'htmlform_exp', 'class' => 'fg_ml_manager fg_html', 'title' => __('HTML Opt-in Code:', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('Enter your html opt-in code.', 'nhp-opts'), 'std' => ''), array('id' => 'ml_html_url', 'type' => 'text', 'class' => 'fg_ml_manager fg_html regular-text', 'title' => __('Form URL', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_html_blank', 'type' => 'checkbox', 'class' => 'fg_ml_manager fg_html', 'title' => __('Submit Form to New Window', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_html_name', 'type' => 'text', 'class' => 'fg_ml_manager fg_html regular-text', 'title' => __('Name Input Name', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 'name'), array('id' => 'ml_html_email', 'type' => 'text', 'class' => 'fg_ml_manager fg_html regular-text', 'title' => __('E-mail Input Name', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 'email'), array('id' => 'ml_html_hidden', 'type' => 'textarea', 'class' => 'fg_ml_manager fg_html regular-text', 'title' => __('Additional HTML Code:', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('Enter additional form HTML, like hidden inputs etc.', 'nhp-opts'), 'std' => ''), array('id' => 'ml_csv_file', 'type' => 'csv_file', 'class' => 'fg_ml_manager fg_csv regular-text', 'title' => __('CSV File Name', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_mc_apikey', 'type' => 'text', 'class' => 'fg_ml_manager fg_mailchimp regular-text', 'title' => __('MailChimp API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://kb.mailchimp.com/article/where-can-i-find-my-api-key" target="_blank">Where can I find my API Key?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_mc_list', 'type' => 'mailchimp_lists', 'class' => 'fg_ml_manager fg_mailchimp regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_mc_double_optin', 'type' => 'select', 'class' => 'fg_ml_manager fg_mailchimp regular-text', 'title' => __('Double Opt-in?', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 0, 'options' => array(0 => 'No', 1 => 'Yes')), array('id' => 'ml_mc_send_welcome', 'type' => 'select', 'class' => 'fg_ml_manager fg_mailchimp regular-text', 'title' => __('Send Welcome Message?', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 1, 'options' => array(0 => 'No', 1 => 'Yes')), array('id' => 'ml_gr_apikey', 'type' => 'text', 'class' => 'fg_ml_manager fg_getresponse regular-text', 'title' => __('GetResponse API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://www.getresponse.com/learning-center/glossary/api-key.html" target="_blank">Where can I find my API Key?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_gr_list', 'type' => 'getresponse_lists', 'class' => 'fg_ml_manager fg_getresponse regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_sendy_url', 'type' => 'text', 'class' => 'fg_ml_manager fg_sendy regular-text', 'title' => __('Sendy Url', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => '', 'std' => ''), array('id' => 'ml_sendy_list', 'type' => 'text', 'class' => 'fg_ml_manager fg_sendy regular-text', 'title' => __('Sendy List ID', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('This encrypted & hashed id can be found under View all lists section named ID', 'nhp-opts'), 'std' => ''), array('id' => 'ml_egoi_apikey', 'type' => 'text', 'class' => 'fg_ml_manager fg_egoi regular-text', 'title' => __('e-goi API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => '', 'std' => ''), array('id' => 'ml_egoi_list', 'type' => 'egoi_lists', 'class' => 'fg_ml_manager fg_egoi regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_dm_form_id', 'type' => 'text', 'class' => 'fg_ml_manager fg_directmail regular-text', 'title' => __('Direct Mail Subscribe Form ID', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://directmailmac.com/support/article/327" target="_blank">Where do I find my form ID?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cm_clientid', 'type' => 'text', 'class' => 'fg_ml_manager fg_campaignmonitor regular-text', 'title' => __('CampaignMonitor Client ID', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://www.campaignmonitor.com/api/getting-started/#clientid" target="_blank">Where can I find my Client ID?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cm_apikey', 'type' => 'text', 'class' => 'fg_ml_manager fg_campaignmonitor regular-text', 'title' => __('CampaignMonitor API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://www.campaignmonitor.com/api/getting-started/#apikey" target="_blank">Where can I find my API Key?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cm_list', 'type' => 'campaignmonitor_lists', 'class' => 'fg_ml_manager fg_campaignmonitor regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_ic_username', 'type' => 'text', 'class' => 'fg_ml_manager fg_icontact regular-text', 'title' => __('iContact Username', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_ic_addid', 'type' => 'text', 'class' => 'fg_ml_manager fg_icontact regular-text', 'title' => __('iContact App ID', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('<a href="http://developer.icontact.com/documentation/register-your-app/" target="_blank">Where can I get my App ID?</a>', 'nhp-opts'), 'std' => ''), array('id' => 'ml_ic_apppass', 'type' => 'text', 'class' => 'fg_ml_manager fg_icontact regular-text', 'title' => __('iContact App Password', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_ic_list', 'type' => 'icontact_lists', 'class' => 'fg_ml_manager fg_icontact regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cc_username', 'type' => 'text', 'class' => 'fg_ml_manager fg_constantcontact regular-text', 'title' => __('Constant Contact Username', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cc_pass', 'type' => 'text', 'input_type' => 'password', 'class' => 'fg_ml_manager fg_constantcontact regular-text', 'title' => __('Constant Contact Password', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cc_list', 'type' => 'constantcontact_lists', 'class' => 'fg_ml_manager fg_constantcontact regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_cc_send_welcome', 'type' => 'select', 'class' => 'fg_ml_manager fg_constantcontact regular-text', 'title' => __('Send Welcome Message?', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 1, 'options' => array(0 => 'No', 1 => 'Yes')), array('id' => 'ml_email', 'type' => 'text', 'class' => 'fg_ml_manager fg_email regular-text', 'title' => __('E-mail Address', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_wy_list', 'type' => 'wysija_lists', 'class' => 'fg_ml_manager fg_wysija regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_mm_list', 'type' => 'mymail_lists', 'class' => 'fg_ml_manager fg_mymail regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_mm_double_optin', 'type' => 'select', 'class' => 'fg_ml_manager fg_mymail regular-text', 'title' => __('Double Opt-in?', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => 0, 'options' => array(0 => 'No', 1 => 'Yes')), array('id' => 'ml_sp_list', 'type' => 'sendpress_lists', 'class' => 'fg_ml_manager fg_sendpress regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_madm_username', 'type' => 'text', 'class' => 'fg_ml_manager fg_madmimi regular-text', 'title' => __('Mad Mimi Username', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_madm_apikey', 'type' => 'text', 'input_type' => 'text', 'class' => 'fg_ml_manager fg_madmimi regular-text', 'title' => __('Mad Mimi API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_madm_list', 'type' => 'madmimi_lists', 'class' => 'fg_ml_manager fg_madmimi regular-text', 'title' => __('Default Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_inf_subdomain', 'type' => 'text', 'class' => 'fg_ml_manager fg_inf regular-text', 'title' => __('Infusionsoft subdomain', 'nhp-opts'), 'desc' => __('.infusionsoft.com', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_inf_apikey', 'type' => 'text', 'input_type' => 'text', 'class' => 'fg_ml_manager fg_inf regular-text', 'title' => __('Infusionsoft API Key', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'ml_inf_list', 'type' => 'infusionsoft_lists', 'class' => 'fg_ml_manager fg_inf regular-text', 'title' => __('Default Group', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '')));
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_updates.png', 'title' => __('Auto Updates', 'nhp-opts'), 'fields' => array(array('id' => 'autoupdates', 'type' => 'checkbox', 'title' => __('Enable Auto Updates', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'purchasecode', 'type' => 'purchasecode', 'title' => __('Purchase Code', 'nhp-opts'), 'desc' => __('<a href="https://help.market.envato.com/hc/en-us/articles/202822600-Where-can-I-find-my-Purchase-Code-" target="_blank">Where can I find my Purchase Code?</a>', 'nhp-opts'), 'std' => '')));
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_promote.png', 'title' => __('Promote', 'nhp-opts'), 'fields' => array(array('id' => 'promo_header', 'type' => 'info', 'title' => __('Earn with Envato Affiliate Program!', 'nhp-opts'), 'desc' => __('<a href="http://codecanyon.net/make_money/affiliate_program" target="_blank">Click here for more info</a>', 'nhp-opts')), array('id' => 'PROMO_ON', 'type' => 'checkbox', 'title' => __('Promote Ninja Popups with Your Affiliate link?', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'PROMO_REF', 'type' => 'text', 'title' => __('Your Envato Username', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => ''), array('id' => 'promo_img', 'type' => 'info2', 'desc' => __('<p style="text-align: center;"><img src="' . SNP_URL . '/admin/img/promote.png" /></p>', 'nhp-opts'), 'std' => '')));
    $sections[] = array('icon' => SNP_NHP_OPTIONS_URL . 'img/ico_adv_settings.png', 'title' => __('Advanced Settings', 'nhp-opts'), 'fields' => array(array('id' => 'enable_taxs', 'type' => 'tax_checkboxes', 'title' => __('Enable Ninja Popups Settings for Taxonomies', 'nhp-opts')), array('id' => 'class_popup', 'type' => 'text', 'title' => __('CSS class used in links', 'nhp-opts'), 'desc' => __('(default: snppopup)', 'nhp-opts'), 'std' => 'snppopup'), array('id' => 'class_no_popup', 'type' => 'text', 'title' => __('CSS class used in links for disable popup', 'nhp-opts'), 'desc' => __('(default: nosnppopup)', 'nhp-opts'), 'std' => 'nosnppopup'), array('id' => 'fb_locale', 'type' => 'select', 'title' => __('Facebook Locale', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'en_GB', 'options' => $FB_Locales), array('id' => 'disable_selftest', 'type' => 'checkbox', 'title' => __('Disable Self Test Warning', 'nhp-opts')), array('id' => 'disable_affiliate_message', 'type' => 'checkbox', 'title' => __('Disable Afilliate Program Notice', 'nhp-opts')), array('id' => 'disable_np_columns', 'type' => 'checkbox', 'title' => __('Don\'t show Ninja Popups column in Posts/Pages Lists', 'nhp-opts')), array('id' => 'run_hook', 'type' => 'select', 'title' => __('Plugin Run Hook', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'get_header', 'options' => array('get_header' => 'get_header', 'wp' => 'wp')), array('id' => 'conflict_header', 'type' => 'info', 'title' => 'JavaScripts', 'desc' => __('If Theme or another Plugin is loading any of these scripts, you can turn it off to avoid conflict.
					', 'nhp-opts')), array('id' => 'js_disable_fancybox', 'type' => 'checkbox', 'title' => __('Disable Fancybox 2 Loading', 'nhp-opts'), 'sub_desc' => 'jquery.fancybox.pack.js'), array('id' => 'js_disable_jq_cookie', 'type' => 'checkbox', 'title' => __('Disable jQuery Cookie', 'nhp-opts'), 'sub_desc' => 'jquery.ck.js<br />(<a href="https://github.com/carhartl/jquery-cookie" target="_blank">https://github.com/carhartl/jquery-cookie</a>)'), array('id' => 'js_disable_jq_placeholder', 'type' => 'checkbox', 'title' => __('Disable jQuery PlaceHolder', 'nhp-opts'), 'sub_desc' => 'jquery.placeholder.js'), array('id' => 'js_disable_fb', 'type' => 'checkbox', 'title' => __('Disable Facebook JS Loading', 'nhp-opts'), 'sub_desc' => 'https://connect.facebook.net/en_GB/all.js#xfbml=1'), array('id' => 'js_disable_gp', 'type' => 'checkbox', 'title' => __('Disable Google Plus JS Loading', 'nhp-opts'), 'sub_desc' => 'https://apis.google.com/js/plusone.js'), array('id' => 'js_disable_tw', 'type' => 'checkbox', 'title' => __('Disable Twitter JS Loading', 'nhp-opts'), 'sub_desc' => 'https://platform.twitter.com/widgets.js'), array('id' => 'js_disable_pi', 'type' => 'checkbox', 'title' => __('Disable Pinterest JS Loading', 'nhp-opts'), 'sub_desc' => 'https://assets.pinterest.com/js/pinit.js'), array('id' => 'js_disable_li', 'type' => 'checkbox', 'title' => __('Disable LinkedIn JS Loading', 'nhp-opts'), 'sub_desc' => 'https://platform.linkedin.com/in.js')));
    $Popups['global'] = 'Use global settings';
    $Popups['disabled'] = 'Disabled';
    $all_post_type = snp_get_post_types();
    $customfields[] = array('id' => 'snp-cf-gsp', 'post_type' => $all_post_type, 'title' => __('Ninja Popups', 'nhp-opts'), 'fields' => array(array('id' => 'p_welcome_popup', 'type' => 'select', 'title' => __('Welcome', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'global', 'options' => $Popups), array('id' => 'p_exit_popup', 'type' => 'select', 'title' => __('Exit', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'global', 'options' => $Popups)));
    // POPUP FILEDS
    $customfields[] = array('id' => 'snp-cf-lf', 'post_type' => array('snp_popups'), 'title' => __('Look & Feel', 'nhp-opts'), 'fields' => array(array('id' => 'theme', 'type' => 'select_theme', 'title' => __('Theme', 'nhp-opts'), 'desc' => __('Please save content data before change.', 'nhp-opts'), 'std' => 'theme1', 'options' => snp_get_themes_list())));
    $customfields[] = array('id' => 'snp-cf-cnt', 'post_type' => array('snp_popups'), 'title' => __('Content', 'nhp-opts'), 'fields' => array());
    $customfields[] = array('id' => 'snp-cf-preview', 'context' => 'side', 'post_type' => array('snp_popups'), 'title' => __('Preview', 'nhp-opts'), 'fields' => array(array('id' => 'popup_preview_popup', 'type' => 'preview_popup', 'title' => __('Preview', 'nhp-opts'), 'disable_title' => 1, 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-overlay', 'post_type' => array('snp_popups'), 'title' => __('Overlay', 'nhp-opts'), 'fields' => array(array('id' => 'popup_overlay', 'type' => 'select_show_fieldsgroup', 'title' => __('Overlay', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'default', 'options' => array('default' => array('name' => 'Default (60% opacity)', 'fieldsgroup' => 'fg_overlay_default'), 'disabled' => array('name' => 'Disabled', 'fieldsgroup' => 'fg_overlay_disabled'), 'image' => array('name' => 'Image', 'fieldsgroup' => 'fg_overlay_image'))), array('id' => 'overlay_image', 'type' => 'upload', 'class' => 'fg_overlay fg_overlay_image regular-text', 'title' => __('Overlay Image', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-gs', 'post_type' => array('snp_popups'), 'title' => __('Display Settings', 'nhp-opts'), 'fields' => array(array('id' => 'start_date', 'type' => 'date', 'title' => __('Start Date', 'nhp-opts'), 'sub_desc' => __('Leave empty to enable popup all the time.', 'nhp-opts')), array('id' => 'end_date', 'type' => 'date', 'title' => __('End Date', 'nhp-opts'), 'sub_desc' => __('Leave empty to enable popup all the time.', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-op', 'post_type' => array('snp_popups'), 'title' => __('Welcome Settings', 'nhp-opts'), 'fields' => array(array('id' => 'open', 'type' => 'select_show_fieldsgroup', 'title' => __('When Popup should appear?', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'default', 'options' => array('load' => array('name' => 'On page load', 'fieldsgroup' => 'open_load'), 'inactivity' => array('name' => 'After X seconds of inactivity', 'fieldsgroup' => 'open_inactivity'), 'scroll' => array('name' => 'When user scroll page', 'fieldsgroup' => 'open_scroll'))), array('id' => 'open_inactivity', 'type' => 'text', 'class' => 'fg_open open_inactivity', 'title' => __('Open after X seconds of inactivity', 'nhp-opts'), 'desc' => __('', 'nhp-opts')), array('id' => 'open_after', 'type' => 'text', 'class' => 'fg_open open_load', 'title' => __('Open Delay', 'nhp-opts'), 'desc' => __('(in seconds)', 'nhp-opts')), array('id' => 'open_scroll', 'type' => 'slider', 'class' => 'fg_open open_scroll mini', 'title' => __('Open when user scroll % of page', 'nhp-opts'), 'desc' => __('% (100% - end of page)', 'nhp-opts'), 'std' => '10', 'min' => '0', 'max' => '100', 'step' => '1')));
    $customfields[] = array('id' => 'snp-cf-ex', 'post_type' => array('snp_popups'), 'title' => __('Exit Settings', 'nhp-opts'), 'fields' => array(array('id' => 'show_on_exit', 'type' => 'select_hide_below', 'title' => __('Show Exit Popup', 'nhp-opts'), 'sub_desc' => __('Only for exit popups.', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 2, 'options' => array(2 => array('name' => 'When user try to leave page (need JS Alert)', 'allow' => 'true'), 3 => array('name' => 'When mouse leaves the browser viewport (Exit Intent)', 'allow' => 'false'), 1 => array('name' => 'When user click external link', 'allow' => 'false'))), array('id' => 'exit_js_alert_text', 'type' => 'textarea', 'title' => __('JavaScript Alert Box Text', 'nhp-opts'), 'sub_desc' => __('Only for exit popups.', 'nhp-opts'), 'desc' => __('<p style="text-align: center;"><img src="' . SNP_URL . '/admin/img/js_alert.png" /></p>', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-cb', 'post_type' => array('snp_popups'), 'title' => __('Close Button & Delay', 'nhp-opts'), 'fields' => array(array('id' => 'cb_close_after', 'type' => 'text', 'class' => 'mini', 'title' => __('Auto Close Popup', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('(in seconds)', 'nhp-opts')), array('id' => 'show_cb_button', 'type' => 'select', 'title' => __('Show Close Link and Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'cb_text', 'type' => 'text', 'title' => __('Close Link Text', 'nhp-opts'), 'std' => __('Close this popup', 'nhp-opts'), 'desc' => __('', 'nhp-opts')), array('id' => 'cb_img', 'type' => 'radio_img', 'title' => __('Close Button', 'nhp-opts'), 'sub_desc' => '', 'desc' => '', 'options' => array('close_default' => array('title' => '', 'img' => SNP_URL . 'img/close_default.png'), 'close_1' => array('title' => '', 'img' => SNP_URL . 'img/close_1.png'), 'close_2' => array('title' => '', 'img' => SNP_URL . 'img/close_2.png'), 'close_3' => array('title' => '', 'img' => SNP_URL . 'img/close_3.png'), 'close_4' => array('title' => '', 'img' => SNP_URL . 'img/close_4.png'), 'close_5' => array('title' => '', 'img' => SNP_URL . 'img/close_5.png'), 'close_6' => array('title' => '', 'img' => SNP_URL . 'img/close_6.png')), 'std' => 'close_default')));
    $customfields[] = array('id' => 'snp-cf-cookies', 'post_type' => array('snp_popups'), 'title' => __('Cookies', 'nhp-opts'), 'fields' => array(array('id' => 'cookie_conversion', 'type' => 'text', 'class' => 'mini', 'title' => __('Cookie Time on Conversion (Opt-in/Share)', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '30', 'desc' => __('days (0 for cookie just for current session, -2 to disable cookie and open popup every time)<br />When user opt-in/share, how long should it be before the popup is shown again?', 'nhp-opts')), array('id' => 'cookie_close', 'type' => 'text', 'class' => 'mini', 'title' => __('Cookie Time on Close', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '0', 'desc' => __('days (0 for cookie just for current session, -2 to disable cookie and open popup every time)<br />When user click close button, how long should it be before the popup is shown again?', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-redirect', 'post_type' => array('snp_popups'), 'title' => __('Redirect', 'nhp-opts'), 'fields' => array(array('id' => 'optin_redirect', 'type' => 'select', 'title' => __('Redirect after opt-in/like', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'no', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'optin_redirect_url', 'type' => 'text', 'title' => __('Redirect URL', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-fb', 'post_type' => array('snp_popups'), 'title' => __('Facebook', 'nhp-opts'), 'fields' => array(array('id' => 'show_like_button', 'type' => 'select', 'title' => __('Show Like Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'fb_url', 'type' => 'text', 'title' => __('URL to Like', 'nhp-opts'), 'sub_desc' => __('Leave empty to use current URL.', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-tw', 'post_type' => array('snp_popups'), 'title' => __('Twitter', 'nhp-opts'), 'fields' => array(array('id' => 'show_tweet_button', 'type' => 'select', 'title' => __('Show Tweet Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'tweet_url', 'type' => 'text', 'title' => __('URL to Tweet', 'nhp-opts'), 'sub_desc' => __('Leave empty to use current URL.', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts')), array('id' => 'tweet_text', 'type' => 'textarea', 'title' => __('Tweet Text', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('', 'nhp-opts')), array('id' => 'show_follow_button', 'type' => 'select', 'title' => __('Show Follow Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'no', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'twitter_username', 'type' => 'text', 'title' => __('Twitter Username', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-gp', 'post_type' => array('snp_popups'), 'title' => __('Google Plus', 'nhp-opts'), 'fields' => array(array('id' => 'show_gp_button', 'type' => 'select', 'title' => __('Show +1 Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'gp_url', 'type' => 'text', 'title' => __('URL to +1', 'nhp-opts'), 'sub_desc' => __('Leave empty to use current URL.', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-li', 'post_type' => array('snp_popups'), 'title' => __('LinkedIn', 'nhp-opts'), 'fields' => array(array('id' => 'show_li_button', 'type' => 'select', 'title' => __('Show InShare Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'li_url', 'type' => 'text', 'title' => __('URL to share', 'nhp-opts'), 'sub_desc' => __('Leave empty to use current URL.', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-pi', 'post_type' => array('snp_popups'), 'title' => __('Pinterest', 'nhp-opts'), 'fields' => array(array('id' => 'show_pi_button', 'type' => 'select', 'title' => __('Show Pin It Button', 'nhp-opts'), 'desc' => __('', 'nhp-opts'), 'std' => 'yes', 'options' => array('yes' => 'Yes', 'no' => 'No')), array('id' => 'pi_url', 'type' => 'text', 'title' => __('URL of the page to pin', 'nhp-opts'), 'sub_desc' => __('Leave empty to use current URL.', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts')), array('id' => 'pi_image_url', 'type' => 'upload', 'title' => __('URL of the image to pin', 'nhp-opts'), 'desc' => __('(start with http://)', 'nhp-opts')), array('id' => 'pi_description', 'type' => 'textarea', 'title' => __('Description ', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-customcss', 'post_type' => array('snp_popups'), 'title' => __('Custom CSS', 'nhp-opts'), 'fields' => array(array('id' => 'custom_css', 'type' => 'textarea', 'title' => __('Custom CSS', 'nhp-opts'))));
    $customfields[] = array('id' => 'snp-cf-customjs', 'post_type' => array('snp_popups'), 'title' => __('Custom JS', 'nhp-opts'), 'fields' => array(array('id' => 'custom_js', 'type' => 'textarea', 'title' => __('Custom JS', 'nhp-opts'))));
    /* == */
    $ml_fields = array();
    if (snp_get_option('ml_manager') == 'email') {
        $ml_fields[] = array('id' => 'ml_email', 'type' => 'text', 'class' => 'fg_ml_manager fg_email regular-text', 'title' => __('E-mail Address', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'aweber') {
        $ml_fields[] = array('id' => 'ml_aw_lists', 'type' => 'aweber_lists', 'class' => 'fg_ml_manager fg_aweber', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'mailchimp') {
        $ml_fields[] = array('id' => 'ml_mc_list', 'type' => 'mailchimp_lists', 'class' => 'fg_ml_manager fg_mailchimp regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'getresponse') {
        $ml_fields[] = array('id' => 'ml_gr_list', 'type' => 'getresponse_lists', 'class' => 'fg_ml_manager fg_getresponse regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'campaignmonitor') {
        $ml_fields[] = array('id' => 'ml_cm_list', 'type' => 'campaignmonitor_lists', 'class' => 'fg_ml_manager fg_campaignmonitor regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'icontact') {
        $ml_fields[] = array('id' => 'ml_ic_list', 'type' => 'icontact_lists', 'class' => 'fg_ml_manager fg_icontact regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'constantcontact') {
        $ml_fields[] = array('id' => 'ml_cc_list', 'type' => 'constantcontact_lists', 'class' => 'fg_ml_manager fg_constantcontact regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'wysija') {
        $ml_fields[] = array('id' => 'ml_wy_list', 'type' => 'wysija_lists', 'class' => 'fg_ml_manager fg_wysija regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'mymail') {
        $ml_fields[] = array('id' => 'ml_mm_list', 'type' => 'mymail_lists', 'class' => 'fg_ml_manager fg_mymail regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'sendpress') {
        $ml_fields[] = array('id' => 'ml_sp_list', 'type' => 'sendpress_lists', 'class' => 'fg_ml_manager fg_sendpress regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'madmimi') {
        $ml_fields[] = array('id' => 'ml_madm_list', 'type' => 'madmimi_lists', 'class' => 'fg_ml_manager fg_madmimi regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'infusionsoft') {
        $ml_fields[] = array('id' => 'ml_inf_list', 'type' => 'infusionsoft_lists', 'class' => 'fg_ml_manager fg_inf regular-text', 'title' => __('Select Group', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'sendy') {
        $ml_fields[] = array('id' => 'ml_sendy_list', 'type' => 'text', 'class' => 'fg_ml_manager fg_sendy regular-text', 'title' => __('Sendy List ID', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'desc' => __('This encrypted & hashed id can be found under View all lists section named ID', 'nhp-opts'), 'std' => '', 'meta' => 1);
    } elseif (snp_get_option('ml_manager') == 'egoi') {
        $ml_fields[] = array('id' => 'ml_egoi_list', 'type' => 'egoi_lists', 'class' => 'fg_ml_manager fg_egoi regular-text', 'title' => __('Select Mailing List', 'nhp-opts'), 'sub_desc' => __('', 'nhp-opts'), 'std' => '', 'meta' => 1);
    }
    if (count($ml_fields) > 0) {
        $customfields[] = array('id' => 'snp-cf-ml', 'post_type' => array('snp_popups'), 'title' => __('Mailing List', 'nhp-opts'), 'fields' => $ml_fields);
    }
    /* == */
    global $SNP_NHP_Options;
    $tabs = array();
    $SNP_NHP_Options = new SNP_NHP_Options($sections, $args, $tabs, $customfields, array(), array());
}
Ejemplo n.º 2
0
<?php

$Popups = snp_get_popups();
$ABTesting = snp_get_ab();
$Popups = (array) $Popups + (array) $ABTesting;
$Popups['global'] = 'Use global settings';
$Popups['disabled'] = 'Disabled';
if ($mode == 'edit') {
    ?>
    <tr class="form-field">
	<th scope="row" valign="top"><label><?php 
    _e('Ninja Popups - Welcome', 'nhp-opts');
    ?>
</label></th>
	<td>
    <?php 
} else {
    ?>
	
    <div class="form-field">
        <label><?php 
    _e('Ninja Popups - Welcome', 'nhp-opts');
    ?>
</label>
    <?php 
}
?>
        <select name="snp_term_meta[welcome]">
	    <?php 
foreach ($Popups as $k => $v) {
    echo '<option ' . (!isset($snp_term_meta['welcome']) && $k == 'global' || $snp_term_meta['welcome'] == $k ? 'selected' : '') . ' value="' . $k . '">' . $v . '</option>';
Ejemplo n.º 3
0
function snp_stats()
{
    global $wpdb;
    echo '<div class="wrap">';
    $popup_ID = htmlspecialchars(addslashes($_REQUEST['popup_ID']));
    $Popups = snp_get_popups();
    $ABTesting = snp_get_ab();
    $Bars = (array) $Popups + (array) $ABTesting;
    if (isset($_REQUEST['start']) && snp_is_valid_date($_REQUEST['start'])) {
        $start = date('Y-m-d', strtotime($_REQUEST['start']));
    }
    if (isset($_REQUEST['end']) && snp_is_valid_date($_REQUEST['end'])) {
        $end = date('Y-m-d', strtotime($_REQUEST['end']));
    }
    if (isset($popup_ID)) {
        $table_name = $wpdb->prefix . "snp_stats";
        $where = '';
        $where2 = '';
        if (strpos($popup_ID, 'ab_') !== FALSE) {
            $AB = true;
            $where = "AB_ID = '" . str_replace('ab_', '', $popup_ID) . "'";
        } else {
            $where = "ID = '{$popup_ID}'";
        }
        if (isset($start)) {
            $where2 .= ' AND `date`>="' . $start . '" ';
        }
        if (isset($end)) {
            $where2 .= ' AND `date`<="' . $end . '" ';
        }
        $stats_sum = $wpdb->get_results("\n\tSELECT SUM(imps) as imps, SUM(convs) as convs, FORMAT((SUM(convs)/SUM(imps))*100,2) as rate\n\tFROM {$table_name}\n\tWHERE {$where} {$where2}\n\t");
        $stats = $wpdb->get_results("\n\tSELECT date,SUM(imps) as imps, SUM(convs) as convs,FORMAT((SUM(convs)/SUM(imps))*100,2) as rate\n\tFROM {$table_name}\n\tWHERE {$where} {$where2}\n\tGROUP BY date\n\tORDER BY date ASC\n\t");
    }
    echo '<h2>' . __('Analytics', 'nhp-opts') . '</h2>';
    echo '<form method="post">';
    echo '<strong>Form:</strong> <select name="popup_ID">';
    echo '<option ' . ($popup_ID == '' ? 'selected' : '') . ' value="">-- select --</option>';
    foreach ($Bars as $ID => $Name) {
        echo '<option ' . ($popup_ID == $ID ? 'selected' : '') . ' value="' . $ID . '">' . $Name . '</option>';
    }
    echo '</select>';
    echo '<strong>Start:</strong> <input type="text" name="start" value="' . (isset($start) ? $start : '') . '" style="text-align: center;" class="snp-datepicker" />
	<strong>End:</strong> <input type="text" name="end" value="' . (isset($end) ? $end : '') . '"style="text-align: center;" class="snp-datepicker" />
	<input class="button button-primary button-large" type="submit" value="Show" />
    </form>
    <script type="text/javascript">
	  jQuery(document).ready(function(){	
		jQuery(".snp-datepicker").datepicker({dateFormat: "yy-mm-dd"});
	  });
    </script>';
    if ($stats) {
        echo '<h3>' . __('Impressions:', 'nhp-opts') . ' ' . $stats_sum[0]->imps . ' / ' . __('Conversions:', 'nhp-opts') . ' ' . $stats_sum[0]->convs . ' / ' . __('Rate:', 'nhp-opts') . ' ' . $stats_sum[0]->rate . '%</h3>';
        ?>
	<br />
	<div id="chart_div_main" style="width: 100%; height: 600px;"></div>
	<?php 
        if ($AB) {
            echo '<h3>' . __('Impressions', 'nhp-opts') . '';
            echo '<div id="chart_div_i" style="width: 100%; height: 600px;"></div>';
            echo '<h3>' . __('Conversions', 'nhp-opts') . '';
            echo '<div id="chart_div_c" style="width: 100%; height: 600px;"></div>';
        }
        ?>
	<script type="text/javascript" src="https://www.google.com/jsapi"></script>
	<script type="text/javascript">
	  google.load("visualization", "1", {packages:["corechart"]});
	  google.setOnLoadCallback(drawChart);
	  function drawChart() 
	  {
	    var data = new google.visualization.DataTable();
	    data.addColumn('string', 'Date');
	    data.addColumn('number', 'Impressions');
	    data.addColumn('number', 'Conversions');
	    data.addRows([
	    <?php 
        $i = 1;
        foreach ($stats as $data) {
            if ($i != 1) {
                echo ',';
            }
            echo "['" . $data->date . "', {v: " . $data->imps . "}, {v: " . $data->convs . ", f: '" . $data->convs . " (" . $data->rate . "%)'}]";
            $i++;
        }
        ?>
	    ]);
	    var options = {
	      title: '',
	      hAxis: {title: '', titleTextStyle: {color: '#333'}},
	      vAxis: {minValue: 0, gridlines:{count: -1}}
	    };
	    var chart = new google.visualization.AreaChart(document.getElementById('chart_div_main'));
	    chart.draw(data, options);
	    <?php 
        if ($AB) {
            ?>
		var data_i = new google.visualization.DataTable();
		data_i.addColumn('string', 'Date');
		var data_c = new google.visualization.DataTable();
		data_c.addColumn('string', 'Date');
		<?php 
            $AB_META = get_post_meta(str_replace('ab_', '', $popup_ID));
            $stat_arr = array();
            if (isset($AB_META['snp_forms'])) {
                $snp_forms = array_keys(unserialize($AB_META['snp_forms'][0]));
                $IDs = array();
                foreach ($snp_forms as $ID) {
                    echo "data_i.addColumn('number', '" . get_the_title($ID) . "');";
                    echo "data_c.addColumn('number', '" . get_the_title($ID) . "');";
                    $IDs[] = $ID;
                    $where1 = " AND ID = '{$ID}' ";
                    $stats2 = $wpdb->get_results("\n\t\t\tSELECT date,SUM(imps) as imps, SUM(convs) as convs,FORMAT(SUM(convs)/SUM(imps),2) as rate\n\t\t\tFROM {$table_name}\n\t\t\tWHERE {$where} {$where1} {$where2}\n\t\t\tGROUP BY date\n\t\t\tORDER BY date ASC\n\t\t\t");
                    if ($stats2) {
                        foreach ($stats2 as $data) {
                            $stat_arr['imps'][$data->date][$ID] = $data->imps;
                            $stat_arr['convs'][$data->date][$ID] = $data->convs;
                            $stat_arr['rate'][$data->date][$ID] = $data->rate;
                        }
                    }
                }
                ?>
		    data_i.addRows([
		    <?php 
                $i = 1;
                foreach ($stat_arr['imps'] as $date => $data) {
                    if ($i != 1) {
                        echo ',';
                    }
                    echo "['" . $date . "'";
                    foreach ($IDs as $ID) {
                        echo ", {v: " . ($stat_arr['imps'][$date][$ID] ? $stat_arr['imps'][$date][$ID] : '0') . "}";
                    }
                    echo "]";
                    $i++;
                }
                ?>
		    ]);
		    data_c.addRows([
		    <?php 
                $i = 1;
                foreach ($stat_arr['convs'] as $date => $data) {
                    if ($i != 1) {
                        echo ',';
                    }
                    echo "['" . $date . "'";
                    foreach ($IDs as $ID) {
                        echo ", {v: " . ($stat_arr['convs'][$date][$ID] ? $stat_arr['convs'][$date][$ID] . ", f: '" . $stat_arr['convs'][$date][$ID] . " (" . $stat_arr['rate'][$date][$ID] . "%)'" : '0') . "}";
                    }
                    echo "]";
                    $i++;
                }
                ?>
		    ]);
		    <?php 
            }
            ?>
		var chart_i = new google.visualization.AreaChart(document.getElementById('chart_div_i'));
		chart_i.draw(data_i, options);
		var chart_c = new google.visualization.AreaChart(document.getElementById('chart_div_c'));
		chart_c.draw(data_c, options);
		<?php 
        }
        ?>
	  }
	</script>
	<?php 
    } else {
        echo '<div class="error"><p><strong>' . __('Nothing to show.', 'nhp-opts') . '</strong></p></div>';
    }
    echo '</div>';
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-datepicker');
    global $wp_scripts;
    $ui = $wp_scripts->query('jquery-ui-core');
    // tell WordPress to load the Smoothness theme from Google CDN
    $protocol = is_ssl() ? 'https' : 'http';
    $url = "{$protocol}://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
    wp_enqueue_style('jquery-ui-smoothness', $url, false, null);
}