ppr_curr_version = '0.1'; $this->ppr_nofollow = array(); $this->ppr_newindow = array(); $this->ppr_url = array(); $this->ppr_url_rewrite = array(); //$this->thepprversion = get_option( 'ppr_version'); //$this->thepprmeta = get_option( 'ppr_meta_clean'); $this->quickppr_redirects = get_option( 'quickppr_redirects', array() ); $this->quickppr_redirectsmeta = get_option( 'quickppr_redirects_meta', array() ); $this->homelink = get_option( 'home'); $this->pproverride_nofollow = get_option( 'ppr_override-nofollow' ); $this->pproverride_newwin = get_option( 'ppr_override-newwindow' ); $this->ppruse_jquery = get_option( 'ppr_use-jquery' ); $this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() ); $this->pproverride_type = get_option( 'ppr_override-redirect-type' ); $this->pproverride_active = get_option( 'ppr_override-active', '0' ); $this->pproverride_URL = get_option( 'ppr_override-URL', '' ); $this->pproverride_rewrite = get_option( 'ppr_override-rewrite', '0' ); $this->pprmeta_message = get_option( 'qppr_meta_addon_content', get_option( 'ppr_meta-message', '' ) ); $this->pprmeta_seconds = get_option( 'qppr_meta_addon_sec', get_option( 'ppr_meta-seconds', 0 ) ); $this->pproverride_casesensitive= get_option( 'ppr_override-casesensitive' ); $this->adminlink = admin_url('/', 'admin'); $this->ppr_metaurl = ''; $this->updatemsg = ''; $this->pprshowcols = get_option( 'ppr_show-columns', '1' ); $this->tag_canonical_handled = false; $this->tag_canonical_printed = false; //if($this->pprmeta_seconds==''){$this->pprmeta_seconds='0';} //these are for all the time - even if there are overrides add_action( 'admin_init', array( $this, 'save_quick_redirects_fields' ) ); add_action( 'admin_init', array( $this, 'ppr_init_check_version' ), 1 ); // checks version of plugin in DB and updates if needed. add_action( 'admin_init', array( $this, 'qppr_meta_plugin_has_addon' ) ); add_action( 'init', array( $this, 'ppr_parse_request_new' ) ); add_action( 'template_redirect', array( $this, 'redirect_tag_to_post' ), 0 ); add_action( 'wp_head', array( $this, 'output_tag_canonical_tag' ), 9999 ); add_filter( 'wpseo_canonical', array( $this, 'filter_tag_archive_canonical' ) ); add_filter( 'rank_math/frontend/canonical', array( $this, 'filter_tag_archive_canonical' ) ); add_filter( 'aioseo_canonical_url', array( $this, 'filter_tag_archive_canonical' ) ); add_filter( 'seopress_titles_canonical', array( $this, 'filter_tag_archive_canonical' ) ); add_filter( 'get_canonical_url', array( $this, 'filter_tag_archive_canonical' ) ); add_action( 'save_post', array( $this,'ppr_save_metadata' ), 11, 2 ); // save the custom fields add_action( 'admin_menu', array( $this,'ppr_add_menu_and_metaboxes' ) ); // add the menu items & Metaboxes needed add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this,'ppr_filter_plugin_actions' ) ); // adds links to plugin list page add_filter( 'plugin_row_meta', array( $this, 'ppr_filter_plugin_links' ), 10, 2 ); // adds links to plugin list page add_action( 'plugins_loaded', array( $this, 'qppr_load_textdomain' ) ); // loads the plugin textdomain - 5.1.2 add_filter( 'query_vars', array( $this, 'ppr_queryhook' ) ); // parse out some form submissions (mainly for import and export) add_action( 'admin_enqueue_scripts' , array( $this, 'qppr_admin_scripts' ) ); // admin scripts & styles add_action( 'admin_enqueue_scripts', array( $this, 'qppr_pointer_load' ), 1000 ); // for new features pointers - 5.0.7 add_action( 'wp_enqueue_scripts' , array( $this, 'qppr_frontend_scripts' ) ); // front end scripts - 5.0.7 add_action( 'wp_ajax_qppr_delete_all_settings', array( $this, 'qppr_delete_all_settings_ajax' ) ); // register ajax delete ALL Settings - 5.1.0 add_action( 'wp_ajax_qppr_delete_all_iredirects', array( $this, 'qppr_delete_all_ireds_ajax' ) ); // register ajax delete ALL Individual Redirects - 5.1.0 add_action( 'wp_ajax_qppr_delete_all_qredirects', array( $this, 'qppr_delete_all_qreds_ajax' ) ); // register ajax delete ALL 1ON1 URL Redirects - 5.1.0 add_action( 'wp_ajax_qppr_delete_quick_redirect', array( $this, 'qppr_delete_quick_redirect_ajax' ) ); // register ajax delete quick redirect - 5.0.7 add_action( 'wp_ajax_qppr_save_quick_redirect', array( $this, 'qppr_save_quick_redirect_ajax' ) ); // register ajax save quick redirect - 5.0.7 add_action( 'wp_ajax_qppr_pprhidemessage_ajax', array( $this, 'qppr_pprhidemessage_ajax' ) ); // register ajax messages quick redirect - 5.0.7 //add_filter( 'qppr_admin_pointers-toplevel_page_redirect-updates', array( $this, 'qppr_register_pointer_existing' ) ); // add pointers filter //add_filter( 'qppr_admin_pointers-quick-redirects_page_redirect-options', array( $this, 'qppr_register_pointer_use_jquery' ) ); // add pointers filter ///add_filter( 'qppr_admin_pointers-quick-redirects_page_meta_addon', array( $this, 'qppr_register_pointer_meta' ) ); // add pointers filter //add_filter( 'wp_feed_cache_transient_lifetime',array($this,'ppr_wp_feed_options',10, 2)); // for testing FAQ page only if( $this->pproverride_active != '1' && !is_admin() ){ // don't run these if override active is set add_action( 'init', array( $this, 'redirect' ), 1 ); // add the 301 redirect action, high priority add_action( 'init', array( $this, 'redirect_post_type' ), 1 ); // add the normal redirect action, high priority add_action( 'ppr_meta_head_hook', array( $this, 'override_ppr_metahead' ), 1, 3 ); // takes care of Meta Redirects as of 5.1.1 add_action( 'template_redirect', array( $this, 'ppr_do_redirect' ), 1); // do the redirects add_filter( 'wp_get_nav_menu_items', array( $this, 'ppr_new_nav_menu_fix' ), 1, 1 );// hook into nav menus add_filter( 'wp_list_pages', array( $this, 'ppr_fix_targetsandrels' ) ); // hook into wp_list_pages function add_filter( 'page_link', array( $this, 'ppr_filter_page_links' ), 20, 2 ); // hook into page_link function add_filter( 'post_link', array( $this, 'ppr_filter_page_links' ), 20, 2 ); // hook into post_link function add_filter( 'post_type_link', array( $this, 'ppr_filter_page_links' ), 20, 2 ); // hook into custom post type link function add_filter( 'get_permalink', array( $this, 'ppr_filter_links' ), 20, 2 ); // hook into get_permalink function //add_filter( 'redirect_canonical', array( $this, 'wordpress_no_guess_canonical' ) ); // stops 404 on canonical redirect as of 5.1.5 } if( $this->pprshowcols == '1') add_filter( 'pre_get_posts', array( $this,'add_custom_columns' ) ); // add custom columns } function wordpress_no_guess_canonical( $redirect_url ){ if ( is_404() ) { $redirects = get_option( 'quickppr_redirects', array() ); $request_URI = isset( $_SERVER['REQUEST_URI'] ) ? rtrim( $_SERVER['REQUEST_URI'], '/' ) . '/' : ''; if( isset( $redirects[$request_URI] ) && !empty( $redirects[$request_URI] ) ) return $redirects[$request_URI]; } return $redirect_url; } function qppr_load_textdomain() { load_plugin_textdomain( '1ON1_URL_Redirects', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); } function qppr_try_to_clear_cache_plugins(){ // make sure the function is present if ( ! function_exists('is_plugin_active')) require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); // WP Super Cache if ( is_plugin_active( 'wp-super-cache/wp-cache.php' ) && function_exists( 'wp_cache_clear_cache' ) ) wp_cache_clear_cache(); // W3 Total Cache if( is_plugin_active( 'w3-total-cache/w3-total-cache.php') && function_exists( 'w3tc_pgcache_flush' ) ) w3tc_pgcache_flush(); // WP Fast Cache if( is_plugin_active( 'wp-fastest-cache/wpFastestCache.php') && class_exists( 'WpFastestCache' ) ){ $newCache = new WpFastestCache(); $newCache->deleteCache(); } } function qppr_delete_all_settings_ajax(){ if ( !current_user_can( 'manage_options' ) ) exit('no permission'); check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true ); if( current_user_can( 'manage_options' ) ){ global $wpdb; //delete Individual $sql = "DELETE FROM {$wpdb->postmeta} WHERE `meta_key` IN ( '_pprredirect_meta_secs','qppr_meta_trigger','qppr_meta_load','qppr_meta_content','qppr_meta_append','_pprredirect_active','_pprredirect_rewritelink','_pprredirect_newwindow','_pprredirect_relnofollow','_pprredirect_type','_pprredirect_url');"; $wpdb->query($sql); //delete Quick delete_option( 'quickppr_redirects' ); delete_option( 'quickppr_redirects_meta' ); //Delete Options delete_option( 'ppr_version'); delete_option( 'ppr_meta_clean'); delete_option( 'ppr_override-nofollow' ); delete_option( 'ppr_override-newwindow' ); delete_option( 'ppr_use-jquery' ); delete_option( 'ppr_qpprptypeok' ); delete_option( 'ppr_override-redirect-type' ); delete_option( 'ppr_override-active' ); delete_option( 'ppr_override-URL' ); delete_option( 'ppr_override-rewrite' ); delete_option( 'qppr_meta_addon_content' ); delete_option( 'ppr_meta-message' ); delete_option( 'qppr_meta_addon_sec' ); delete_option( 'ppr_meta-seconds' ); delete_option( 'ppr_override-casesensitive' ); delete_option( 'ppr_show-columns' ); delete_option( 'ppr_use-custom-post-types' ); delete_option( 'qppr_jQuery_hide_message2' ); delete_option( 'qppr_meta_addon_load' ); delete_option( 'qppr_meta_addon_trigger' ); delete_option( 'qppr_meta_append_to' ); $this->qppr_try_to_clear_cache_plugins(); echo 'success'; }else{ echo 'no permission'; } exit; } function qppr_delete_all_ireds_ajax(){ if ( !current_user_can( 'manage_options' ) ) exit('no permission'); check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true ); if( current_user_can( 'manage_options' ) ){ global $wpdb; $sql = "DELETE FROM {$wpdb->postmeta} WHERE `meta_key` IN ( '_pprredirect_meta_secs','qppr_meta_trigger','qppr_meta_load','qppr_meta_content','qppr_meta_append','_pprredirect_active','_pprredirect_rewritelink','_pprredirect_newwindow','_pprredirect_relnofollow','_pprredirect_type','_pprredirect_url');"; $wpdb->query($sql); $this->qppr_try_to_clear_cache_plugins(); echo 'success'; }else{ echo 'no permission'; } exit; } function qppr_delete_all_qreds_ajax(){ if ( !current_user_can( 'manage_options' ) ) exit('no permission'); check_ajax_referer( 'qppr_ajax_delete_ALL_verify', 'security', true ); if( current_user_can( 'manage_options' ) ){ delete_option( 'quickppr_redirects' ); delete_option( 'quickppr_redirects_meta' ); $this->qppr_try_to_clear_cache_plugins(); echo 'success'; }else{ echo 'no permission'; } exit; } function qppr_pointer_load( $hook_suffix ) { $screen = get_current_screen(); $screen_id = $screen->id; $pointers = apply_filters( 'qppr_admin_pointers-' . $screen_id, array() ); if ( ! $pointers || ! is_array( $pointers ) ) return; $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); $valid_pointers =array(); foreach ( $pointers as $pointer_id => $pointer ) { if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) continue; $pointer['pointer_id'] = $pointer_id; $valid_pointers['pointers'][] = $pointer; } if ( empty( $valid_pointers ) ) return; wp_enqueue_style( 'wp-pointer' ); //wp_enqueue_script( 'qppr-pointer', plugins_url( 'js/qppr_pointers.js', __FILE__ ), array( 'wp-pointer' ) ); wp_enqueue_script( 'qppr-pointer', plugins_url( 'js/qppr_pointers.min.js', __FILE__ ), array( 'wp-pointer' ) ); wp_localize_script( 'qppr-pointer', 'qpprPointer', $valid_pointers ); } function qppr_register_pointer_meta( $p ) { $p['qppr-meta-options'] = array( 'target' => '.wrap > h2:first-child', 'options' => array( 'content' => sprintf( '
%s
', __( 'New Meta Redirect options.' ,'1ON1_URL_Redirects'), __( 'Please view the Help Tab above to see more information about the Meta Redirect Settings.', '1ON1_URL_Redirects') ), 'position' => array( 'edge' => 'top', 'align' => 'right' ) ) ); return $p; } function qppr_register_pointer_existing( $p ) { $p['existing-redirects'] = array( 'target' => '#qppr-existing-redirects', 'options' => array( 'content' => sprintf( '%s
%s
', __( 'New Layout of Existing Redirects' ,'1ON1_URL_Redirects'), __( 'The existing 1ON1 URL Redirects are now laid out in a list format instead of form fields. When you have a lot of Redirects, this helps eliminate the "max_input_vars" configuration issue where redirects were not saving correctly.','1ON1_URL_Redirects'), __( 'To edit an existing redirect, click the pencil icon','1ON1_URL_Redirects'). ' () ' .__( 'and the row will become editable. Click the trash can icon','1ON1_URL_Redirects').' () '.__( 'and the redirect will be deleted. Click the trash can icon','1ON1_URL_Redirects') ), 'position' => array( 'edge' => 'bottom', 'align' => 'left' ) ) ); return $p; } function qppr_register_pointer_use_jquery( $p ) { $p['qppr-use-jquery'] = array( 'target' => '#ppr_use-jquery', 'options' => array( 'content' => sprintf( '%s
%s
%s
', __( 'New Option to Use jQuery' ,'1ON1_URL_Redirects'), __( 'To increase the effectiveness of the plugin\'s ability to add new window and nofollow functionality, you can use the jQuery option.','1ON1_URL_Redirects'), __( 'This adds JavaScript/jQuery scripting to check the links in the output HTML of the page and add the correct functionality if needed.','1ON1_URL_Redirects'), __( 'If you experience JavaScript/jQuery conflicts, try turning this option off.','1ON1_URL_Redirects') ), 'position' => array( 'edge' => 'left', 'align' => 'middle' ) ) ); return $p; } function qppr_delete_quick_redirect_ajax(){ if ( !current_user_can( 'manage_options' ) ) exit('error'); check_ajax_referer( 'qppr_ajax_verify', 'security', true ); $request = isset($_POST['request']) && esc_url($_POST['request']) != '' ? esc_url($_POST['request']) : ''; $curRedirects = get_option( 'quickppr_redirects', array() ); $curMeta = get_option( 'quickppr_redirects_meta', array() ); if( isset( $curRedirects[ $request ] ) && isset( $curMeta[ $request ] ) ){ unset( $curRedirects[ $request ] , $curMeta[ $request ] ); update_option('quickppr_redirects', $curRedirects); update_option('quickppr_redirects_meta', $curMeta); $this->qppr_try_to_clear_cache_plugins(); echo 'redirect deleted'; }else{ echo 'error'; } exit; } function qppr_save_quick_redirect_ajax(){ if ( !current_user_can( 'manage_options' ) ) exit('error'); check_ajax_referer( 'qppr_ajax_verify', 'security', true ); $protocols = apply_filters('qppr_allowed_protocols',array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp')); $request = isset($_POST['request']) && trim($_POST['request']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['request'])), null, 'appip') : ''; $requestOrig = isset($_POST['original']) && trim($_POST['original']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['original'])), null, 'appip') : ''; $destination = isset($_POST['destination']) && trim($_POST['destination']) != '' ? esc_url(str_replace(' ','%20',trim($_POST['destination'])), null, 'appip') : ''; $newWin = isset($_POST['newwin']) && (int) trim($_POST['newwin']) == 1 ? 1 : 0; $noFollow = isset($_POST['nofollow']) && (int) trim($_POST['nofollow']) == 1 ? 1 : 0; $updateRow = isset($_POST['row']) && $_POST['row'] != '' ? (int) str_replace('rowpprdel-','',$_POST['row']) : -1; $curRedirects = get_option('quickppr_redirects', array()); $curMeta = get_option('quickppr_redirects_meta', array()); $rkeys = array_keys($curRedirects); $mkeys = array_keys($curMeta); if( $updateRow == -1 || $requestOrig == '' || $request == '' || $destination == '' || empty( $curRedirects ) || empty( $curMeta) ){ echo 'error'; exit; } $toDelete = array(); $newRedirects = array(); $newMeta = array(); $orkey = array_search($requestOrig, $rkeys); $omkey = array_search($requestOrig, $mkeys); if( is_array( $rkeys ) && ! empty( $rkeys ) ){ foreach( $rkeys as $key => $val ){ $newRedirects[] = array( 'request' => $val, 'destination' => $curRedirects[$val] ); } } if( is_array( $mkeys ) && ! empty( $mkeys ) ){ foreach( $mkeys as $key => $val ){ $newMeta[] = array( 'key' => $val, 'newwindow' => ( isset( $curMeta[$val]['newwindow'] ) && $curMeta[$val]['newwindow'] != '' ? $curMeta[$val]['newwindow'] : 0 ), 'nofollow' => ( isset( $curMeta[$val]['nofollow'] ) && $curMeta[$val]['nofollow'] != '' ? $curMeta[$val]['nofollow'] : 0 ) ); } } $originalRowKey = isset($rkeys[$orkey]) ? $rkeys[$orkey] : ''; $originalRowMetaKey = isset($mkeys[$omkey]) ? $mkeys[$omkey] : ''; if( $originalRowKey == $request ){ //if row to update has same request value then just update destination $newRedirects[$orkey] = array( 'request' => $request, 'destination' => $destination ); }else{ if( isset( $curRedirects[$request] ) ){ echo 'duplicate'; exit; }else{ $newRedirects[$orkey] = array( 'request' => $request, 'destination' => $destination ); } } if( !empty( $newRedirects ) ){ $curRedirects = array(); foreach($newRedirects as $red){ $curRedirects[$red['request']] = $red['destination']; } } if( $originalRowMetaKey == $request ){ //if row to udpate has same request value then just update data $newMeta[$omkey]['key'] = $request; $newMeta[$omkey]['newwindow'] = $newWin; $newMeta[$omkey]['nofollow'] = $noFollow; }else{ if( isset( $curMeta[$request] ) ){ echo 'duplicate'; exit; }else{ $newMeta[$omkey]['key'] = $request; $newMeta[$omkey]['newwindow'] = $newWin; $newMeta[$omkey]['nofollow'] = $noFollow; } } if( !empty( $newMeta ) ){ $curMeta = array(); foreach($newMeta as $meta){ $curMeta[$meta['key']]['newwindow'] = $meta['newwindow']; $curMeta[$meta['key']]['nofollow'] = $meta['nofollow']; } } // now save data back to the db options update_option('quickppr_redirects', $curRedirects); update_option('quickppr_redirects_meta', $curMeta); $this->qppr_try_to_clear_cache_plugins(); echo 'saved'; exit; } function save_quick_redirects_fields(){ if( isset( $_POST['submit_301'] ) ) { if( check_admin_referer( 'add_qppr_redirects' )){ $this->quickppr_redirects = $this->save_redirects( $_POST['quickppr_redirects'] ); $this->updatemsg = __( '1ON1 URL Redirects Updated.', '1ON1_URL_Redirects' ); $this->qppr_try_to_clear_cache_plugins(); } } //if submitted and verified, process the data } function save_redirects($data){ // Save the redirects from the options page to the database // As of version 5.0.7 the redirects are saved by adding to the existing ones, not resaving all of them from form - // this was to prevent the max_input_vars issue when that was set low and there were a lot of redirects. $currRedirects = get_option( 'quickppr_redirects', array() ); $currMeta = get_option( 'quickppr_redirects_meta', array() ); //TODO: Add Back up Redirects //TODO: Add New Redirects to TOP not Bottom. $protocols = apply_filters( 'qppr_allowed_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp')); for($i = 0; $i < sizeof($data['request']); ++$i) { $request = esc_url(str_replace(' ','%20',trim($data['request'][$i])), null, 'appip'); $destination = esc_url(str_replace(' ','%20',trim($data['destination'][$i])), null, 'appip'); $newwin = isset($data['newwindow'][$i]) && (int)(trim($data['newwindow'][$i])) == 1 ? 1 : 0; $nofoll = isset($data['nofollow'][$i]) && (int)(trim($data['nofollow'][$i])) == 1 ? 1 : 0; if( strpos($request,'/',0) !== 0 && !$this->qppr_strposa($request,$protocols)){ $request = '/'.$request; } // adds root marker to front if not there if((strpos($request,'.') === false && strpos($request,'?') === false) && strpos($request,'/',strlen($request)-1) === false){ $request = $request.'/'; } // adds end folder marker if not a file end if (($request == '' || $request == '/') && $destination == '') { continue; //if nothing there do nothing } elseif ($request != '' && $request != '/' && $destination == '' ){ $currRedirects[$request] = '/'; } else { $currRedirects[$request] = $destination; } $currMeta[$request]['newwindow'] = $newwin; $currMeta[$request]['nofollow'] = $nofoll; } update_option( 'quickppr_redirects', sanitize_option( 'quickppr_redirects', $currRedirects ) ); update_option( 'quickppr_redirects_meta', sanitize_option( 'quickppr_redirects_meta', $currMeta ) ); $this->quickppr_redirectsmeta = get_option( 'quickppr_redirects_meta', array() ); $this->quickppr_redirects = get_option( 'quickppr_redirects', array() ); return $currRedirects; } function qppr_strposa($haystack, $needle, $offset = 0) { if( !is_array( $needle ) ) $needle = array( $needle ); foreach( $needle as $key => $query ) { if(strpos($haystack, $query, $offset) !== false) return true; // stop on first true result } return false; } function add_custom_columns(){ /* Add Column Headers */ $usetypes = get_option( 'ppr_use-custom-post-types', 0 ) != 0 ? 1 : 0; if( $usetypes == 1 ){ $post_types_temp = get_post_types( array( 'public' => true ) ); if( count( $post_types_temp ) == 0){ $post_types_temp = array( 'page' => 'page', 'post' => 'post', 'attachment' => 'attachment', 'nav_menu_item' => 'nav_menu_item' ); } unset( $post_types_temp['revision'] ); // remove revions from array if present as they are not needed. unset( $post_types_temp['attachment'] ); // remove from array if present as they are not needed. unset( $post_types_temp['nav_menu_item'] ); // remove from array if present as they are not needed. $ptypesNOTok = is_array( $this->pprptypes_ok ) ? $this->pprptypes_ok : array(); foreach( $post_types_temp as $type ){ if( in_array( $type, $ptypesNOTok ) ){ continue; }else{ if( $type == 'post' ){ add_filter( "manage_post_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_post_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); }elseif( $type == 'page' ){ //add_filter( "manage_page_pages_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); //add_action( "manage_page_pages_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); add_filter( "manage_page_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_page_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); }else{ add_filter( "manage_{$type}_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_{$type}_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); add_filter( "manage_{$type}_pages_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_{$type}_pages_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); } } } }else{ //if not use custom post types, just use pages and posts. add_filter( "manage_post_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_post_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); //add_filter( "manage_page_pages_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); //add_action( "manage_page_pages_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); add_filter( "manage_page_posts_columns", array( $this, 'set_custom_edit_qppr_columns' ) ); add_action( "manage_page_posts_custom_column" , array( $this, 'custom_qppr_column' ), 10, 2 ); } } function set_custom_edit_qppr_columns($columns) { $columns['qppr_redirect'] = __( 'Redirect', '1ON1_URL_Redirects' ); return $columns; } function custom_qppr_column( $column, $post_id ) { switch ( $column ) { case 'qppr_redirect' : $qppr_url = get_post_meta( $post_id , '_pprredirect_url', true ) != '' ? get_post_meta( $post_id , '_pprredirect_url', true ) : ''; if( $qppr_url != '' ){ $qppr_type = get_post_meta( $post_id , '_pprredirect_type', true ); $qppr_active = get_post_meta( $post_id , '_pprredirect_active', true ); $qppr_rewrite = get_post_meta( $post_id , '_pprredirect_rewritelink', true ); $qppr_newwin = get_post_meta( $post_id , '_pprredirect_newwindow', true ); $qppr_nofoll = get_post_meta( $post_id , '_pprredirect_relnofollow', true ); $rediricon = $qppr_newwin != '' ? '' : ''; if($qppr_active == '1'){ echo ''.$qppr_url.''.$qppr_url.'' . __( 'The FAQS are now on a feed that can be updated on the fly. If you have a question and don\'t see an answer, please send an email to info@anadnet.com and ask your question. If it is relevant to the plugin, it will be added to the FAQs feed so it will show up here. Please be sure to include the plugin you are asking a question about (1ON1 URL Redirects Plugin) and any other information like your WordPress version and examples if the plugin is not working correctly for you. THANKS!', '1ON1_URL_Redirects' ) . '
updatemsg;?>
' . $this->updatemsg . '
|
( |
|
|
( |
|
updatemsg;?>
| Example Requests | Example Destinations | |
|---|---|---|
/about.htm |
» | '.$this->homelink.'/about/ |
/directory/landing/ |
» | /about/ |
'. str_replace("http://", "https://",$this->homelink).'/contact-us/ |
» | '.$this->homelink.'/contact-us-new/ |
/ at the beginning.', '1ON1_URL_Redirects' ) . 'https://, use it as the protocol. Our best guess is that your domain and protocol are', '1ON1_URL_Redirects' ) . ' '.network_site_url('/').'http://www.mysite.com/destination-page/ OR /destination-page/target and rel properties to the link to make it work.', '1ON1_URL_Redirects' ) . '' . __( 'You can export redirects in two formats - Encoded or Delimited.', '1ON1_URL_Redirects' ) . '
Help content coming soon.
' . __( 'Use the Load Content? option to allow the page content to load as normal or to only load a blank page or the content provided in the Page Content section. ', '1ON1_URL_Redirects' ) . '
' . __( 'If checked, all of the original content will load, so keep this in mind when setting the Redirect Seconds - if set too low, the page will not compeletely load. ', '1ON1_URL_Redirects' ) . '
' . __( 'Enter the nuber of seconds to wait before the redirect happens. Enter 0 to have an instant redirect*.', '1ON1_URL_Redirects' ) . '
' . __( '*Keep in mind that the redirect seconds will start counting only AFTER the Redirect Trigger element is loaded - so 0 may be slightly longer than instant, depending on how much content needs to load before the trigger happens.', '1ON1_URL_Redirects' ) . '
' . __( 'The class or id or tag name of the element to load before the redirect starts counting down. If nothing is used, it will default to the body tag as a trigger.', '1ON1_URL_Redirects' ) . '
' . __( 'If you use a class, the class name should have the "." in the name, i.e., .my-class-name', '1ON1_URL_Redirects' ) . '
' . __( 'If you use an id, the id should have the "#" in the name, i.e., #my-id-name.', '1ON1_URL_Redirects' ) . '
' . __( 'If you use a tag name, the name should NOT have the "<" or ">" characters in the name, i.e., <body> would just be body.', '1ON1_URL_Redirects' ) . '
' . __( 'Do not use a tag name that is common, like "a" or "div" as it will trigger on all events.', '1ON1_URL_Redirects' ) . '
' . __( 'The class, id or tag name that you want the content in the Page Content to be loading into.', '1ON1_URL_Redirects' ) . '
' . __( 'If you are loading the content of the page, use an existing class or id for an existing element (i.e., .page-content) so your additional page content (if any) is loaded into that element.', '1ON1_URL_Redirects' ) . '
' . __( 'When no class, id or tag name is used, the body tag will be used.', '1ON1_URL_Redirects' ) . '
' . __( 'This is your page content you want to add. If you have a "tracking pixel" script or image tag you want to use, add it here.', '1ON1_URL_Redirects' ) . '
' . __( 'A good example of use, is adding a tracking script (or Facebook Conversion Pixel) to the Page Content box and unchecking the Load Content? box. Then set the Redirect Seconds to 1 or 2 so the script has a chance to load and set Append Content To to "body" and Redirect Trigger to "body".', '1ON1_URL_Redirects' ) . '
' . __( 'Additionally, you can add the redirect counter to the page by adding the code sample under the Page Content box.', '1ON1_URL_Redirects' ) . '
updatemsg;?>
Request URL field, and the URL it should be redirected to in the Destination URL field. To delete a redirect, click the trash can at the end of that row. To edit a redirect, click the pencil edit icon.', '1ON1_URL_Redirects' );?>
redirect|destination', __( 'ERROR - Not a valid File', '1ON1_URL_Redirects' ), array( 'response' => '200', 'back_link' => '1' ) );
exit;
} else {
$tempArr = array();
$tempMArr = array();
$config_file = str_replace("\r\n", "\n", $config_file);
$config_file = str_replace("\r", "\n", $config_file);
$QR_Array = explode( "\n", $config_file );
$newfile1 = array();
if( !empty( $QR_Array ) && is_array( $QR_Array )):
foreach( $QR_Array as $qrtoadd ):
if( $qrtoadd != '' && $delim != false && strpos( $qrtoadd, $delim ) !== false ){
$elem = explode( $delim, str_replace( array( "\r", "\n" ), array( '', '' ), $qrtoadd ) );
if( isset( $elem[0] ) && isset( $elem[1] ) ){
$newfile1['quickppr_redirects'][esc_url($elem[0])] = esc_url($elem[1]);
$nw = isset($elem[2]) && $elem[2] == '1' ? '1' : '0';
$nf = isset($elem[3]) && $elem[3] == '1' ? '1' : '0';
$newfile1['quickppr_redirects_meta'][$elem[0]]['newwindow'] = $nw;
$newfile1['quickppr_redirects_meta'][$elem[0]]['nofollow'] = $nf;
}
}
endforeach;
if(is_array($newfile1) && !empty( $newfile1 )){
if( isset( $newfile1['quickppr_redirects'] ) ){
$currQRs = get_option( 'quickppr_redirects', array() );
$resultQRs = array_replace($currQRs, $newfile1['quickppr_redirects']);
update_option( 'quickppr_redirects', $resultQRs );
}
if( isset( $newfile1['quickppr_redirects_meta'] ) ){
$currQRM = get_option( 'quickppr_redirects_meta', array() );
$resultQRMs = array_replace($currQRM, $newfile1['quickppr_redirects_meta']);
update_option( 'quickppr_redirects_meta', $resultQRMs );
}
}
$this->qppr_try_to_clear_cache_plugins();
wp_redirect(admin_url('admin.php?page=redirect-import-export&update=5'),302);
exit;
else:
wp_die( __( 'It does not look like there are any valid items to import - check the file and try again.', '1ON1_URL_Redirects' ) , __( 'ERROR - No Valid items to add.', '1ON1_URL_Redirects' ), array( 'response' => '200', 'back_link' => '1' ) );
exit;
endif;
}
}
} return;
} return;
}
function qppr_pprhidemessage_ajax(){
check_ajax_referer( 'qppr_ajax_verify', 'scid', true );
$msg = isset($_POST['pprhidemessage']) ? (int)$_POST['pprhidemessage'] : 0;
if($msg == 1){
update_option('qppr_jQuery_hide_message','1');
echo '1';
}elseif($msg == 2){
update_option('qppr_jQuery_hide_message2','1');
echo '1';
}else{
echo '0';
}
exit;
}
function ppr_init_check_version() {
// checks version of plugin in DB and updates if needed.
/* global $wpdb;
//$this->pprptypes_ok = get_option( 'ppr_qpprptypeok', array() );
if( is_array( $this->ppr_all_redir_array ) && ! empty( $this->ppr_all_redir_array ) )
$this->ppr_all_redir_array = $this->get_main_array();
if ( version_compare( $this->thepprversion, $this->ppr_curr_version, '<' ) && version_compare( $this->ppr_curr_version, '5.1.1', '<' ) ){
$metaMsg = get_option( 'ppr_meta-message', 'not-set' );
$metaMsgNew = get_option( 'qppr_meta_addon_content', 'not-set' );
if( $metaMsgNew == 'not-set' && $metaMsg != 'not-set' ){
update_option( 'qppr_meta_addon_content', $metaMsg );
$this->pprmeta_message = $metaMsg;
}
$metaSec = get_option( 'ppr_meta-seconds', 'not-set' );
$metaSecNew = get_option( 'qppr_meta_addon_sec', 'not-set');
if( $metaSecNew == 'not-set' && $metaSec != 'not-set' ){
update_option( 'qppr_meta_addon_sec', $metaSec );
$this->pprmeta_seconds = $metaSec;
}
if( $this->thepprversion == '5.0.7' ){
update_option( 'ppr_use-jquery','1'); //default to on
update_option( 'ppr_show-columns','1'); //default to on
}elseif( $this->thepprversion != '5.1.0' ){
if ( get_option( 'ppr_override-casesensitive' , 'not-set' ) == 'not-set' )
update_option( 'ppr_override-casesensitive', '1' );
$this->ppruse_jquery = '0';
$this->pproverride_casesensitive = '1';
}
update_option( 'ppr_version', $this->ppr_curr_version );
}elseif( version_compare( $this->thepprversion, $this->ppr_curr_version, '<' ) ){
update_option( 'ppr_version', $this->ppr_curr_version );
}
if( $this->thepprmeta != '1' && version_compare( $this->ppr_curr_version, '5.0.7', '<' )){
update_option( 'ppr_meta_clean', '1' );
$wpdb->query("UPDATE $wpdb->postmeta SET `meta_key` = CONCAT('_',`meta_key`) WHERE `meta_key` = 'pprredirect_active' OR `meta_key` = 'pprredirect_rewritelink' OR `meta_key` = 'pprredirect_newwindow' OR `meta_key` = 'pprredirect_relnofollow' OR `meta_key` = 'pprredirect_type' OR `meta_key` = 'pprredirect_url';");
} */
}
function ppr_filter_plugin_actions($links){
//$links[] = ' ' . __( 'Settings', '1ON1_URL_Redirects' ) . '';
return $links;
}
function ppr_filter_plugin_links($links, $file){
/* if ( $file == plugin_basename(__FILE__) ){
$links[] = ' ' . __( '1ON1 URL Redirects', '1ON1_URL_Redirects' ) . '';
$links[] = ' ' . __( 'FAQ', '1ON1_URL_Redirects' ) . '';
$links[] = ' ' . __( 'Donate', '1ON1_URL_Redirects' ) . '';
}*/
return $links;
}
function edit_box_ppr_1() {
// Prints the inner fields for the custom post/page section
global $post;
$ppr_option1='';
$ppr_option2='';
$ppr_option3='';
$ppr_option4='';
$ppr_option5='';
// Use nonce for verification ... ONLY USE ONCE!
wp_nonce_field( 'pprredirect_noncename', 'pprredirect_noncename', false, true );
// The actual fields for data entry
$pprredirecttype = get_post_meta($post->ID, '_pprredirect_type', true) !='' ? get_post_meta($post->ID, '_pprredirect_type', true) : "";
$pprredirecturl = get_post_meta($post->ID, '_pprredirect_url', true)!='' ? get_post_meta($post->ID, '_pprredirect_url', true) : "";
echo '