options = affcoups_get_options(); add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) ); add_action( 'admin_init', array( &$this, 'init_settings' ) ); add_action( 'affcoups_admin_header_after', array( &$this, 'render_settings_nav' ) ); $this->init_active_tab(); } /** * Add admin menu */ function add_admin_menu() { add_submenu_page( 'edit.php?post_type=affcoups_coupon', __( 'Settings', 'affiliate-coupons' ), // Page title __( 'Settings', 'affiliate-coupons' ), // Menu title 'manage_options', // Capabilities 'affcoups_settings', // Menu slug array( &$this, 'options_page' ) // Callback ); } /** * Render page header */ function render_settings_nav() { if ( ! affcoups_is_plugin_admin_area_settings() ) return; ?>
> $_GET: ' . $active_tab ); } else { $active_tab = get_transient( 'affcoups_settings_active_tab' ); //affcoups_debug_log( 'init_active_tab >> transient: ' . $active_tab ); } //affcoups_debug_log( $active_tab ); $this->active_tab = ( ! empty( $active_tab ) ) ? $active_tab : 'quickstart'; //affcoups_debug_log( $this->active_tab ); } /** * Get registered settings * * @return array */ function get_registered_settings() { $settings = array( /** * Filters the default "Quickstart" settings. * * @param array $settings */ 'quickstart' => apply_filters( 'affcoups_settings_quickstart', array( 'icon' => 'welcome-learn-more', 'title' => __( 'Quickstart Guide', 'affiliate-coupons' ), 'callback' => array( &$this, 'section_quickstart_render' ), 'fields' => array() ) ), /** * Filters the default "General" settings. * * @param array $settings */ 'general' => apply_filters( 'affcoups_settings_general', array( 'icon' => 'admin-generic', 'title' => __( 'General', 'affiliate-coupons' ), 'fields' => array( 'order' => array( 'title' => __( 'Sorting', 'affiliate-coupons' ), 'callback' => array( &$this, 'order_render' ) ), 'search_filters' => array( 'title' => __( 'Coupon Search Filters', 'affiliate-coupons' ), 'callback' => array( &$this, 'search_filters_render' ) ), 'pagination' => array( 'title' => __( 'Pagination', 'affiliate-coupons' ), 'callback' => array( &$this, 'pagination_render' ) ), 'templates' => array( 'title' => __( 'Templates', 'affiliate-coupons' ), 'callback' => array( &$this, 'templates_render' ) ), 'styles' => array( 'title' => __( 'Styles', 'affiliate-coupons' ), 'callback' => array( &$this, 'styles_render' ) ), 'title_linked' => array( 'title' => __( 'Title', 'affiliate-coupons' ), 'callback' => array( &$this, 'title_render' ) ), 'vendor_logo' => array( 'title' => __( 'Show Vendor Logo', 'affiliate-coupons' ), 'callback' => array( &$this, 'vendor_logo_render' ) ), 'description' => array( 'title' => __( 'Description', 'affiliate-coupons' ), 'callback' => array( &$this, 'description_render' ) ), 'discount' => array( 'title' => __( 'Discount', 'affiliate-coupons' ), 'callback' => array( &$this, 'discount_render' ) ), 'codes' => array( 'title' => __( 'Codes', 'affiliate-coupons' ), 'callback' => array( &$this, 'code_render' ) ), 'button' => array( 'title' => __( 'Button', 'affiliate-coupons' ), 'callback' => array( &$this, 'button_render' ) ), 'clipboard' => array( 'title' => __( 'Clipboard', 'affiliate-coupons' ), 'callback' => array( &$this, 'clipboard_render' ) ), 'dates' => array( 'title' => __( 'Dates', 'affiliate-coupons' ), 'callback' => array( &$this, 'dates_render' ) ), 'social_share' => array( 'title' => __( 'Social Share', 'affiliate-coupons' ), 'callback' => array( &$this, 'social_share_render' ) ), 'credits' => array( 'title' => __( 'Credits', 'affiliate-coupons' ), 'callback' => array( &$this, 'credits_render' ) ), 'custom_css' => array( 'title' => __( 'Custom CSS', 'affiliate-coupons' ), 'callback' => array( &$this, 'custom_css_render' ) ) ) ) ), /** * Filters the default "Help" settings. * * @param array $settings */ 'help' => apply_filters( 'affcoups_settings_quickstart', array( 'icon' => 'sos', 'title' => __( 'Help & Support', 'affiliate-coupons' ), 'callback' => array( &$this, 'section_help_render' ), 'fields' => array() ) ), ); $settings = apply_filters( 'affcoups_settings', $settings ); return $settings; } /** * Register settings */ function init_settings() { // Register setting register_setting( 'affcoups_settings', 'affcoups_settings', array( &$this, 'validate_input_callback' ) ); // Define settings page slug $settings_page = 'affcoups_settings'; // Register sections foreach( $this->get_registered_settings() as $section_key => $section ) { add_settings_section( 'affcoups_settings_' . $section_key, ( ! empty( $section['title'] ) ) ? $section['title'] : __return_null(), ( isset( $section['callback'] ) ) ? $section['callback'] : '__return_false', $settings_page ); // Register fields if ( isset( $section['fields'] ) && is_array( $section['fields'] ) ) { foreach ( $section['fields'] as $field_key => $field ) { add_settings_field( 'affcoups_settings_' . $field_key, ( ! empty( $field['title'] ) ) ? $field['title'] : __return_null(), ( isset( $field['callback'] ) ) ? $field['callback'] : '__return_false', $settings_page, 'affcoups_settings_' . $section_key ); } } } } /** * Validate settings input * * @param $input * @return mixed */ function validate_input_callback( $input ) { //affcoups_debug_log( $input ); // Handle Active Tab if ( ! empty( $input['active_tab'] ) ) { set_transient( 'affcoups_settings_active_tab', $input['active_tab'], 20 ); // Remember for 20 seconds only $input['active_tab'] = ''; } // Handle Delete Log Action if ( isset ( $input['delete_log'] ) && '1' === $input['delete_log'] ) { delete_option( 'affcoups_log' ); $input['delete_log'] = '0'; } $input = apply_filters( 'affcoups_settings_validate_input', $input ); return $input; } /** * Render quickstart section */ function section_quickstart_render() { ?>



[affcoups] [affcoups max="10"]

[affcoups id="123"] [affcoups id="123,456,789"]


[affcoups search_filters="true"] [affcoups search_filters="false"]

[affcoups pagination="true"] [affcoups pagination="false"]

[affcoups pagination_per_page="5"]


[affcoups hide_invalid="true"] [affcoups hide_invalid="false"]


[affcoups expired="true"] [affcoups expired="false"]


[affcoups template="standard"]

standard, grid, list & banner

[affcoups grid="2"], [affcoups grid="3"] etc.


[affcoups title_display="hide"]

[affcoups description="hide"]

[affcoups image_hide="true"]


[affcoups_vendor_list]


documentation for more options.', 'affiliate-coupons' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( add_query_arg( array( 'utm_source' => 'settings-page', 'utm_medium' => 'quickstart', 'utm_campaign' => 'Affiliate Coupons', ), 'https://affcoups.com/docs/' ) ) ); ?>

__( 'Show', 'affiliate-coupons' ), 'hide' => __( 'Hide', 'affiliate-coupons' ) ); $code_options = apply_filters( 'affcoups_settings_code_options', $code_options ); $code = ( isset( $this->options['code'] ) ) ? $this->options['code'] : ''; $reveal_code_option = ( isset( $this->options['reveal_code_option'] ) )? $this->options['reveal_code_option'] : '0'; $login_to_see_code = (isset( $this->options['login_to_see_code'] ) && $this->options['login_to_see_code']=='1')? 1 : 0; $login_msg = (isset( $this->options['login_msg'] )) ? $this->options['login_msg'] : 'Login to see the code!!!'; $login_url = (isset( $this->options['login_url'] )) ? $this->options['login_url'] : ''; ?>

       

/>
">

/>
>
>

__( 'None', 'affiliate-coupons' ), 'cut' => __( 'Cut', 'affiliate-coupons' ), 'cut-white' => __( 'Cut (White)', 'affiliate-coupons' ), 'copy' => __( 'Copy', 'affiliate-coupons' ), 'copy-white' => __( 'Copy (White)', 'affiliate-coupons' ), 'paste' => __( 'Paste', 'affiliate-coupons' ), 'paste-white' => __( 'Paste (White)', 'affiliate-coupons' ) ); $clipboard_icon = ( isset( $this->options['clipboard_icon'] ) ) ? $this->options['clipboard_icon'] : ''; $clipboard_bg_color = ( isset( $this->options['clipboard_bg_color'] ) ) ? $this->options['clipboard_bg_color'] : ''; $clipboard_color = ( isset( $this->options['clipboard_color'] ) ) ? $this->options['clipboard_color'] : ''; ?>

the_color_picker_note(); ?> options['hide_dates'] ) && $this->options['hide_dates'] == '1' ) ? 1 : 0; $hide_invalid_coupons = ( isset( $this->options['hide_invalid_coupons'] ) && $this->options['hide_invalid_coupons'] == '1' ) ? 1 : 0; $hide_expired_coupons = ( isset( $this->options['hide_expired_coupons'] ) && $this->options['hide_expired_coupons'] == '1' ) ? 1 : 0; $show_expiry_countdown = ( isset( $this->options['show_expiry_countdown'] ) && $this->options['show_expiry_countdown'] == '1' ) ? 1 : 0; ?>

/>

/>

/>

/>

/>

__( 'Ascending ', 'affiliate-coupons' ), 'desc' => __( 'Descending', 'affiliate-coupons' ) ); $order = ( isset ( $this->options['order'] ) ) ? $this->options['order'] : 'desc'; $orderby = ( isset ( $this->options['orderby'] ) ) ? $this->options['orderby'] : 'date'; ?>

options['template'] ) ) ? $this->options['template'] : 'grid'; $grid_size = ( ! empty( $this->options['grid_size'] ) && is_numeric( $this->options['grid_size'] ) ) ? intval( $this->options['grid_size'] ) : 3; ?>

options['style'] ) ) ? $this->options['style'] : 'standard'; ?>

options[$key] ) ) { unset( $this->options[$key] ); $update = true; } } if ( $update ) { update_option( 'affcoups_settings', $this->options ); } } /** * Pagination settings */ function pagination_render() { // Early check the (PRO) Pagination settings $this->maybe_unset_pagination_settings(); ?>

options['title_linked'] ) && $this->options['title_linked'] == '1' ) ? 1 : 0; $title_display_options = array( '' => __( 'Show', 'affiliate-coupons' ), 'hide' => __( 'Hide', 'affiliate-coupons' ) ); $title_display_option = ( isset( $this->options['title_display'] ) ) ? $this->options['title_display'] : ''; ?>

>

options['vendor_logo'] ) && $this->options['vendor_logo'] == '1' ) ? 1 : 0; $vendor_logo_display_options = array( '' => __( 'Hide', 'affiliate-coupons' ), 'show' => __( 'Show', 'affiliate-coupons' ) ); $vendor_logo_display_option = ( isset( $this->options['vendor_logo'] ) ) ? $this->options['vendor_logo'] : ''; ?>

options['excerpt_length'] ) && is_numeric( $this->options['excerpt_length'] ) ) ? intval( $this->options['excerpt_length'] ) : 90; $description_options = array( '' => __( 'Show', 'affiliate-coupons' ), 'hide' => __( 'Hide', 'affiliate-coupons' ) ); $description_option = ( isset( $this->options['description'] ) ) ? $this->options['description'] : ''; ?>

options['discount_bg_color'] ) ) ? $this->options['discount_bg_color'] : ''; $discount_color = ( isset( $this->options['discount_color'] ) ) ? $this->options['discount_color'] : ''; ?>

the_color_picker_note(); ?> options['button_text'] ) ) ? esc_attr( trim( $this->options['button_text'] ) ) : __( 'Go to the deal', 'affiliate-coupons' ); $button_icon_options = array( '' => __( 'None', 'affiliate-coupons' ), 'thumbs-up' => __( 'Thumbs up', 'affiliate-coupons' ), 'thumbs-up-white' => __( 'Thumbs up (White)', 'affiliate-coupons' ), 'hand-right' => __( 'Hand right', 'affiliate-coupons' ), 'hand-right-white' => __( 'Hand right (White)', 'affiliate-coupons' ), 'gavel' => __( 'Gavel', 'affiliate-coupons' ), 'gavel-white' => __( 'Gavel (White)', 'affiliate-coupons' ), 'cart' => __( 'Shopping cart', 'affiliate-coupons' ), 'cart-white' => __( 'Shopping cart (White)', 'affiliate-coupons' ) ); $button_icon = ( isset( $this->options['button_icon'] ) ) ? $this->options['button_icon'] : ''; $button_bg_color = ( isset( $this->options['button_bg_color'] ) ) ? $this->options['button_bg_color'] : ''; $button_color = ( isset( $this->options['button_color'] ) ) ? $this->options['button_color'] : ''; ?>

the_color_picker_note(); ?> options['social_share'] ) && $this->options['social_share'] == '1' ) ? 1 : 0; if ( affcoups_is_pro_version() ){ ?>

/>

options['social_share_msg'] ) ) ? esc_attr( trim( $this->options['social_share_msg'] ) ) : __( 'Checkout this offer : ', 'affiliate-coupons-pro' ); ?>

options['show_credits'] ) && $this->options['show_credits'] == '1' ) ? 1 : 0; ?>

/>

options['custom_css_activated'] ) && $this->options['custom_css_activated'] == '1' ) ? 1 : 0; $custom_css = ( ! empty( $this->options['custom_css'] ) ) ? $this->options['custom_css'] : ''; ?>

>



.affcoups .affcoups-coupon { background-color: #333; }

check_curl(); $enabled = ' ' . __('Enabled', 'affiliate-coupons') . ''; $disabled = ' ' . __('Disabled', 'affiliate-coupons') . ''; $uninstall_on_delete = ( isset( $this->options['uninstall_on_delete'] ) && $this->options['uninstall_on_delete'] == '1' ) ? 1 : 0; ?>

WordPress Version
PHP Version

red, please get in contact with your webhoster in order to enable the missing PHP extensions.', 'affiliate-coupons'); ?>


>

true, 'version' => $version ); } else { return false; } } /** * Output the options page HTML */ function options_page() { ?>
affcoups_do_settings_sections( 'affcoups_settings' ); ?>

 

do us a big favor and give us a review for our plugin.', 'affiliate-coupons' ); ?>

active_tab ) $content_classes .= ' active'; echo '
'; echo '
'; if ( $section['title'] ) { echo "

{$section['title']}

\n"; } echo '
'; if ( $section['callback'] ) { call_user_func( $section['callback'], $section ); } echo ''; do_settings_fields( $page, $section['id'] ); echo '
'; echo '
'; // .inside echo '
'; // .card echo '
'; // .affcoups-settings-content } } } }