options = affcoups_get_options(); add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) ); add_action( 'admin_init', array( &$this, 'init_settings' ) ); $this->init_active_tab(); } /** * Add admin menu */ function add_admin_menu() { // Source: https://codex.wordpress.org/Function_Reference/add_options_page add_submenu_page( 'edit.php?post_type=affcoups_coupon', __( 'Affiliate Coupons - Settings', 'affiliate-coupons' ), // Page title __( 'Settings', 'affiliate-coupons' ), // Menu title 'manage_options', // Capabilities 'affcoups_settings', // Menu slug array( &$this, 'options_page' ) // Callback ); } /** * Init active settings tab */ function init_active_tab() { if ( isset( $_GET['tab'] ) ) { $active_tab = $_GET['tab']; //affcoups_debug_log( 'init_active_tab >> $_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' ) ), 'templates' => array( 'title' => __( 'Templates', 'affiliate-coupons' ), 'callback' => array( &$this, 'templates_render' ) ), 'styles' => array( 'title' => __( 'Styles', 'affiliate-coupons' ), 'callback' => array( &$this, 'styles_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' ) ), '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 hideesc_html_expired="true"] [affcoups hide_expired="false"]


[affcoups template="standard"]

standard, grid, list & widget

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

documentation for more options.', 'affiliate-coupons' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( add_query_arg( array( 'utm_source' => 'settings-page', 'utm_medium' => 'quickstart', 'utm_campaign' => 'Affiliate Coupons', ), AFFCOUPS_DOCS_URL ) ) ); ?>

__( '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'] : ''; ?>

__( '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_expired_coupons = ( isset( $this->options['hide_expired_coupons'] ) && $this->options['hide_expired_coupons'] == '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['excerpt_length'] ) && is_numeric( $this->options['excerpt_length'] ) ) ? intval( $this->options['excerpt_length'] ) : 90; ?>

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['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() { ?>

    get_registered_settings() as $section_key => $section ) { ?>
affcoups_do_settings_sections( 'affcoups_settings' ); ?>

Resources & Support

  • 'settings-page', 'utm_medium' => 'infobox-resources', 'utm_campaign' => 'Affiliate Coupons', ), AFFCOUPS_DOCS_URL ) ); ?>

{$section['title']}\n"; } $content_classes = 'affcoups-settings-content'; if ( $section_key === $this->active_tab ) $content_classes .= ' active'; echo '
'; echo '
'; echo $title; echo '
'; if ( $section['callback'] ) { call_user_func( $section['callback'], $section ); } echo ''; do_settings_fields( $page, $section['id'] ); echo '
'; echo '
'; // .inside echo '
'; // .postbox echo '
'; // .affcoups-settings-content } } } }