'slug', 'title' => 'Affiliate Link Base', 'type' => 'text', 'description' => "You can change the default base part '/go/' of your redirect link to something else" ), array( 'name' => 'default', 'title' => 'Default URL for Redirect', 'type' => 'text', 'description' => 'Enter the default URL for redirect if correct URL not set' ), array( 'name' => 'nofollow', 'title' => 'Nofollow Affiliate Links', 'type' => 'checkbox', 'description' => 'Add "X-Robots-Tag: noindex, nofollow" to HTTP headers' ), array( 'name' => 'category', 'title' => 'Show Category in Link URL', 'type' => 'checkbox', 'description' => 'Show the link category slug in the affiliate link URL' ), array( 'name' => 'stats', 'title' => 'Count Hits', 'type' => 'checkbox', 'description' => 'Track the number of times affiliate links have been used' ), array( 'name' => 'redirect', 'title' => 'Redirect Type', 'type' => 'radio', 'description' => 'Set redirection HTTP status code', 'values' => array( '301' => '301 Moved Permanently', '302' => '302 Found', '307' => '307 Temporary Redirect' ) ), ); /** * Hook into the appropriate actions when the class is constructed. */ public function __construct() { add_action( 'admin_menu', array( $this, 'add_admin_menu' ) ); add_action( 'admin_init', array( $this, 'settings_init' ) ); add_filter( 'plugin_action_links_' . AFFILIATE_LINKS_BASENAME, array( $this, 'add_action_links' ) ); } /** * Add settings links */ function add_action_links( $links ) { $links[] = '' . __( 'Settings', Affiliate_Links::$text_domain ) . ''; $links[] = '' . __( 'Go Premium', Affiliate_Links::$text_domain ) . ''; return $links; } public function add_admin_menu() { add_submenu_page( 'edit.php?post_type=affiliate-links', 'Affiliate Links Settings', 'Settings', 'manage_options', 'affiliate_links', array( $this, 'affiliate_links_options_page' ) ); } /** * Register plugin settings. */ public function settings_init() { register_setting( 'affiliate_links', 'affiliate_links_settings' ); add_settings_section( 'affiliate_links_settings', __( 'Configure your link redirection here', Affiliate_Links::$text_domain ), array( $this, 'affiliate_links_settings_callback'), 'affiliate_links' ); foreach ($this->fields as $field) { add_settings_field( $field['name'], __( $field['title'], Affiliate_Links::$text_domain ), array( $this, 'render_'.$field['type'].'_field' ), 'affiliate_links', 'affiliate_links_settings', $field ); } } public function affiliate_links_settings_callback($arg) { //echo ''; } /** * Generate text input field. */ public function render_text_field($args) { $value = isset( Affiliate_Links::$settings[ $args['name'] ] ) ? Affiliate_Links::$settings[ $args['name'] ] : ''; ?>

> $value ) { ?> >
' . __( $args['description'], Affiliate_Links::$text_domain ) . '

'; } /** * Plugin settings page HTML. */ public function affiliate_links_options_page() { $this->flush_rules(); ?>