init_lang(); $this->load_options(); add_action('save_post', array($this, 'save_postdata')); add_action('do_meta_boxes', array($this, 'add_custom_box'), 15, 2); add_action('admin_menu', array($this, 'modify_menu')); } public static function activate() { parent::activate(); } public static function deactivate() { parent::deactivate(); } public static function uninstall() { parent::uninstall(); } function save_postdata($post_id) { if (!wp_verify_nonce($_REQUEST['wp_noextrenallinks_noncename'], plugin_basename(__FILE__))) { return $post_id; } if ('page' == $_REQUEST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } update_post_meta($post_id, 'wp_noextrenallinks_mask_links', $_REQUEST['wp_noextrenallinks_mask_links']); } function add_custom_box($page, $context) { add_meta_box('wp_noextrenallinks_sectionid1', __('Link masking for this post', 'affiliate-tools'), array($this, 'inner_custom_box1'), 'post', 'advanced'); add_meta_box('wp_noextrenallinks_sectionid1', __('Link masking for this post', 'affiliate-tools'), array($this, 'inner_custom_box1'), 'page', 'advanced'); } function inner_custom_box1() { global $post; echo ''; $mask = get_post_meta($post->ID, 'wp_noextrenallinks_mask_links', true); if ($mask === '') $mask = 0; echo '' . __('Use default policy from plugin settings', 'affiliate-tools') . '
' . __('Don`t mask links', 'affiliate-tools'); } function update() { if ( isset($_REQUEST['options']) ) { if ( ! isset( $_POST['aff_tools_nonce_field'] ) || ! wp_verify_nonce( $_POST['aff_tools_nonce_field'], 'submit_aff_tools_options' ) ) { wp_die( '

Sorry, your account did not verify!

' ); } else { $this->options = $_REQUEST['options']; $this->update_options(); echo '
' . __('Options updated.', 'affiliate-tools') . '
'; $this->load_options(); } } } function modify_menu() { add_options_page( 'Affiliate Tools', 'Affiliate Tools', 'manage_options', __FILE__, array($this, 'admin_options') ); } function show_navi() { if (isset($_REQUEST['action']) == 'stats') { ?>
show_navi(); ?>

options['aff_stats']) { _e('Statistic for plugin is disabled! Please, go to options page and enable it via checkbox "Log all outgoing clicks".', 'affiliate-tools'); echo '
'; } else { if ($_REQUEST['date1']) $date1 = $_REQUEST['date1']; else $date1 = date('Y-m-d'); if ($_REQUEST['date2']) $date2 = $_REQUEST['date2']; else $date2 = date('Y-m-d'); _e('View stats from', 'affiliate-tools'); ?>
prefix . 'links_stats where `date` between %s and DATE_ADD(%s,INTERVAL 1 DAY)'; $sql = $wpdb->prepare($sql, $date1, $date2); $result = $wpdb->get_results($sql, ARRAY_A); if (is_array($result) && sizeof($result)) { $out = array(); foreach ($result as $row) { $nfo = parse_url($row['url']); if ($row['url'] && $nfo['host']) $out[$nfo['host']][$row['url']]++; } foreach ($out as $host => $arr) { echo '
' . $host . ''; } } else _e('No statistics for given period.', 'affiliate-tools'); } } function option_page() { ?>
show_navi();?>
' . __('Global links masking settings', 'affiliate-tools') . '' . '(' . __('You can also disable plugin on per-post basis', 'affiliate-tools') . ')'; ?>

' . __('Affiliate Link', 'affiliate-tools') . '

' . __('Config plugin with your affiliate (AccessTrade, MasOffer) account.', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'aff_platform'); // Masking type echo '

' . __('Choose masking type', 'affiliate-tools') . '

' . __('Default masking type is via 302 redirects. Please choose one of the following mods if you do not like it:', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'type'); // What mask echo '

' . __('What to mask', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'what'); echo '

' . __('What to exclude from masking', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'exclude'); echo '

' . __('Common configuration', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'common'); echo '

' . __('Link encoding', 'affiliate-tools') . '

' . __('Those options are not secure enough if you want to protect your data from someone but are quite enough to make link not human-readable. Please choose one of them:', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'encode'); echo '

' . __('Configuration for javascript redirects (if enabled)', 'affiliate-tools') . '

'; $this->show_option_group($opt, 'java'); ?>
show_option($arr); echo '
'; } } } function show_option($opt) { switch($opt['type']) { case 'chk' : $layout = get_chk_option($this->options, $opt); break; case 'txt' : $layout = get_txt_option($this->options, $opt); break; case 'text' : $layout = get_text_option($this->options, $opt); break; case 'slt' : $layout = get_slt_option($this->options, $opt); break; case 'site_slt' : $layout = get_custom_site_slt_option($this->options, $opt); break; case 'aff_plat_key' : $layout = get_aff_plat_key_option($this->options, $opt); break; } echo $layout; } function admin_options() { echo '

Affiliate Tools Settings

'; if (isset($_REQUEST['submit'])){ $this->update(); } if (isset($_REQUEST['action']) == 'stats') { $this->view_stats(); } else { $this->option_page(); } echo '
'; } } ?>