Changeset 2457799
- Timestamp:
- 01/17/2021 11:39:13 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quick-pagepost-redirect-plugin/trunk/page_post_redirect_plugin.php
r2449356 r2457799 104 104 add_action( 'admin_init', array( $this, 'ppr_init_check_version' ), 1 ); // checks version of plugin in DB and updates if needed. 105 105 add_action( 'admin_init', array( $this, 'qppr_meta_plugin_has_addon' ) ); 106 add_action( 'init', array( $this, 'ppr_parse_request_new' ) ); // parse query vars106 add_action( 'init', array( $this, 'ppr_parse_request_new' ) ); // parse query vars 107 107 add_action( 'save_post', array( $this,'ppr_save_metadata' ), 11, 2 ); // save the custom fields 108 108 add_action( 'admin_menu', array( $this,'ppr_add_menu_and_metaboxes' ) ); // add the menu items & Metaboxes needed … … 177 177 // make sure the function is present 178 178 if ( ! function_exists('is_plugin_active')) 179 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );179 require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); 180 180 181 181 // WP Super Cache … … 753 753 echo ' 754 754 <div class="wrap"> 755 <h2>' . __( 'Quick Page/Post Redirect FAQs/Help', 'quick-pagepost-redirect-plugin' ) . '</h2>755 <h2>' . __( 'Quick Page/Post Redirect FAQs/Help', 'quick-pagepost-redirect-plugin' ) . '</h2> 756 756 <div align="left"><p>' . __( '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 <a href="mailto:[email protected]">[email protected]</a> 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 (Quick Page/Post Redirect Plugin) and any other information like your WordPress version and examples if the plugin is not working correctly for you. THANKS!', 'quick-pagepost-redirect-plugin' ) . '</p> 757 757 <hr noshade color="#C0C0C0" size="1" /> … … 761 761 $linkcontent = array(); 762 762 if (!is_wp_error( $rss ) ) : 763 $maxitems = $rss->get_item_quantity( 100 );764 $rss_items = $rss->get_items( 0, $maxitems );763 $maxitems = $rss->get_item_quantity( 100 ); 764 $rss_items = $rss->get_items( 0, $maxitems ); 765 765 endif; 766 766 $aqr = 0; 767 if ($maxitems != 0){768 foreach ( $rss_items as $item ) :769 $aqr++;770 $linkfaq[] = '<li class="faq-top-item"><a href="#faq-'.$aqr.'">'.esc_html( $item->get_title() ).'</a></li>';771 $linkcontent[] = '<li class="faq-item"><a name="faq-'.$aqr.'"></a><h3 class="qa"><span class="qa">Q. </span>'.esc_html( $item->get_title() ).'</h3><div class="qa-content"><span class="qa answer">A. </span>'.$item->get_content().'</div><div class="toplink"><a href="#faq-top">top ↑</a></li>';772 endforeach;767 if ($maxitems != 0){ 768 foreach ( $rss_items as $item ) : 769 $aqr++; 770 $linkfaq[] = '<li class="faq-top-item"><a href="#faq-'.$aqr.'">'.esc_html( $item->get_title() ).'</a></li>'; 771 $linkcontent[] = '<li class="faq-item"><a name="faq-'.$aqr.'"></a><h3 class="qa"><span class="qa">Q. </span>'.esc_html( $item->get_title() ).'</h3><div class="qa-content"><span class="qa answer">A. </span>'.$item->get_content().'</div><div class="toplink"><a href="#faq-top">top ↑</a></li>'; 772 endforeach; 773 773 } 774 774 echo '<a name="faq-top"></a><h2>'.__('Table of Contents','quick-pagepost-redirect-plugin').'</h2>'; … … 929 929 } 930 930 ?> 931 </tbody>931 </tbody> 932 932 </table> 933 933 </div> … … 1210 1210 '; 1211 1211 $screen->add_help_tab( array( 1212 'id' => 'qppr_sample_redirects',1213 'title' => __( 'Examples', 'quick-pagepost-redirect-plugin' ),1214 'content' => $content ,1212 'id' => 'qppr_sample_redirects', 1213 'title' => __( 'Examples', 'quick-pagepost-redirect-plugin' ), 1214 'content' => $content , 1215 1215 ) ); 1216 1216 $screen->add_help_tab( array( 1217 'id' => 'qppr_add_redirects',1218 'title' => __( 'Troubleshooting', 'quick-pagepost-redirect-plugin' ),1219 'content' => '1220 <div style="padding:10px 0;">1217 'id' => 'qppr_add_redirects', 1218 'title' => __( 'Troubleshooting', 'quick-pagepost-redirect-plugin' ), 1219 'content' => ' 1220 <div style="padding:10px 0;"> 1221 1221 <b style="color:red;">' . __( 'IMPORTANT TROUBLESHOOTING NOTES:', 'quick-pagepost-redirect-plugin' ) . '</b> 1222 1222 <ol style="margin-top:5px;"> … … 1238 1238 }elseif( $screen_id == 'quick-redirects_page_redirect-import-export' ){ 1239 1239 $screen->add_help_tab( array( 1240 'id' => 'qppr_export_redirects',1241 'title' => __( 'Export Redirects', 'quick-pagepost-redirect-plugin' ),1242 'content' => '<div style="padding:10px 0;"><p>' . __( 'You can export redirects in two formats - Encoded or Delimited.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1240 'id' => 'qppr_export_redirects', 1241 'title' => __( 'Export Redirects', 'quick-pagepost-redirect-plugin' ), 1242 'content' => '<div style="padding:10px 0;"><p>' . __( 'You can export redirects in two formats - Encoded or Delimited.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1243 1243 ) ); 1244 1244 $screen->add_help_tab( array( 1245 'id' => 'qppr_import_redirects',1246 'title' => __( 'Import Redirects', 'quick-pagepost-redirect-plugin' ),1247 'content' => '<div style="padding:10px 0;"><p>Help content coming soon.</p></div>' ,1245 'id' => 'qppr_import_redirects', 1246 'title' => __( 'Import Redirects', 'quick-pagepost-redirect-plugin' ), 1247 'content' => '<div style="padding:10px 0;"><p>Help content coming soon.</p></div>' , 1248 1248 ) ); 1249 1249 }elseif( $screen_id == 'quick-redirects_page_meta_addon' ){ 1250 1250 $screen->add_help_tab( array( 1251 'id' => 'qppr-load-page-content',1252 'title' => __( 'Load Content?', 'quick-pagepost-redirect-plugin' ),1253 'content' => '<div style="padding:10px 0;"><p>' . __( 'Use the <strong>Load Content?</strong> option to allow the page content to load as normal or to only load a blank page or the content provided in the <strong>Page Content</strong> section. ', 'quick-pagepost-redirect-plugin' ) . '</p>1254 <p>' . __( 'If checked, all of the original content will load, so keep this in mind when setting the <strong>Redirect Seconds</strong> - if set too low, the page will not compeletely load. ', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1251 'id' => 'qppr-load-page-content', 1252 'title' => __( 'Load Content?', 'quick-pagepost-redirect-plugin' ), 1253 'content' => '<div style="padding:10px 0;"><p>' . __( 'Use the <strong>Load Content?</strong> option to allow the page content to load as normal or to only load a blank page or the content provided in the <strong>Page Content</strong> section. ', 'quick-pagepost-redirect-plugin' ) . '</p> 1254 <p>' . __( 'If checked, all of the original content will load, so keep this in mind when setting the <strong>Redirect Seconds</strong> - if set too low, the page will not compeletely load. ', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1255 1255 ) ); 1256 1256 $screen->add_help_tab( array( 1257 'id' => 'qppr-redirect-seconds',1258 'title' => __( 'Redirect Seconds', 'quick-pagepost-redirect-plugin' ),1259 'content' => '<div style="padding:10px 0;"><p>' . __( 'Enter the nuber of seconds to wait before the redirect happens. Enter 0 to have an instant redirect*.', 'quick-pagepost-redirect-plugin' ) . '</p>1260 <p>' . __( '*Keep in mind that the redirect seconds will start counting only AFTER the <strong>Redirect Trigger</strong> element is loaded - so 0 may be slightly longer than instant, depending on how much content needs to load before the trigger happens.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1257 'id' => 'qppr-redirect-seconds', 1258 'title' => __( 'Redirect Seconds', 'quick-pagepost-redirect-plugin' ), 1259 'content' => '<div style="padding:10px 0;"><p>' . __( 'Enter the nuber of seconds to wait before the redirect happens. Enter 0 to have an instant redirect*.', 'quick-pagepost-redirect-plugin' ) . '</p> 1260 <p>' . __( '*Keep in mind that the redirect seconds will start counting only AFTER the <strong>Redirect Trigger</strong> element is loaded - so 0 may be slightly longer than instant, depending on how much content needs to load before the trigger happens.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1261 1261 ) ); 1262 1262 $screen->add_help_tab( array( 1263 'id' => 'qppr-redirect-trigger',1264 'title' => __( 'Redirect Trigger', 'quick-pagepost-redirect-plugin' ),1265 'content' => '<div style="padding:10px 0;"><p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p>1266 <p>' . __( 'If you use a class, the class name should have the "." in the name, i.e., <strong>.my-class-name</strong>', 'quick-pagepost-redirect-plugin' ) . '</p>1267 <p>' . __( 'If you use an id, the id should have the "#" in the name, i.e., <strong>#my-id-name</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>1268 <p>' . __( 'If you use a tag name, the name should NOT have the "<" or ">" characters in the name, i.e., <body> would just be <strong>body</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p>1269 <p>' . __( 'Do not use a tag name that is common, like "a" or "div" as it will trigger on all events.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1263 'id' => 'qppr-redirect-trigger', 1264 'title' => __( 'Redirect Trigger', 'quick-pagepost-redirect-plugin' ), 1265 'content' => '<div style="padding:10px 0;"><p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p> 1266 <p>' . __( 'If you use a class, the class name should have the "." in the name, i.e., <strong>.my-class-name</strong>', 'quick-pagepost-redirect-plugin' ) . '</p> 1267 <p>' . __( 'If you use an id, the id should have the "#" in the name, i.e., <strong>#my-id-name</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p> 1268 <p>' . __( 'If you use a tag name, the name should NOT have the "<" or ">" characters in the name, i.e., <body> would just be <strong>body</strong>.', 'quick-pagepost-redirect-plugin' ) . '</p> 1269 <p>' . __( 'Do not use a tag name that is common, like "a" or "div" as it will trigger on all events.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1270 1270 ) ); 1271 1271 $screen->add_help_tab( array( 1272 'id' => 'qppr-redirect-append',1273 'title' => __( 'Append Content To', 'quick-pagepost-redirect-plugin' ),1274 'content' => '<div style="padding:10px 0;"><p>' . __( 'The class, id or tag name that you want the content in the <strong>Page Content</strong> to be loading into.', 'quick-pagepost-redirect-plugin' ) . '</p>1275 <p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p>1276 <p>' . __( 'When no class, id or tag name is used, the <strong>body</strong> tag will be used.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1272 'id' => 'qppr-redirect-append', 1273 'title' => __( 'Append Content To', 'quick-pagepost-redirect-plugin' ), 1274 'content' => '<div style="padding:10px 0;"><p>' . __( 'The class, id or tag name that you want the content in the <strong>Page Content</strong> to be loading into.', 'quick-pagepost-redirect-plugin' ) . '</p> 1275 <p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p> 1276 <p>' . __( 'When no class, id or tag name is used, the <strong>body</strong> tag will be used.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1277 1277 ) ); 1278 1278 $screen->add_help_tab( array( 1279 'id' => 'qppr-redirect-content',1280 'title' => __( 'Page Content', 'quick-pagepost-redirect-plugin' ),1281 'content' => '<div style="padding:10px 0;"><p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p>1282 <p>' . __( 'A good example of use, is adding a tracking script (or Facebook Conversion Pixel) to the <strong>Page Content box</strong> and unchecking the <strong>Load Content?</strong> box. Then set the <strong>Redirect Seconds</strong> to 1 or 2 so the script has a chance to load and set <strong>Append Content</strong> To to "body" and <strong>Redirect Trigger</strong> to "body".', 'quick-pagepost-redirect-plugin' ) . '</p>1283 <p>' . __( 'Additionally, you can add the redirect counter to the page by adding the code sample under the <strong>Page Content</strong> box.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' ,1279 'id' => 'qppr-redirect-content', 1280 'title' => __( 'Page Content', 'quick-pagepost-redirect-plugin' ), 1281 'content' => '<div style="padding:10px 0;"><p>' . __( '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.', 'quick-pagepost-redirect-plugin' ) . '</p> 1282 <p>' . __( 'A good example of use, is adding a tracking script (or Facebook Conversion Pixel) to the <strong>Page Content box</strong> and unchecking the <strong>Load Content?</strong> box. Then set the <strong>Redirect Seconds</strong> to 1 or 2 so the script has a chance to load and set <strong>Append Content</strong> To to "body" and <strong>Redirect Trigger</strong> to "body".', 'quick-pagepost-redirect-plugin' ) . '</p> 1283 <p>' . __( 'Additionally, you can add the redirect counter to the page by adding the code sample under the <strong>Page Content</strong> box.', 'quick-pagepost-redirect-plugin' ) . '</p></div>' , 1284 1284 ) ); 1285 1285 } … … 2252 2252 $hook_name = 'ppr_meta_head_hook'; 2253 2253 // check URL override 2254 if($this->pproverride_URL !=''){2254 if($this->pproverride_URL !=''){ 2255 2255 $urlsite = $this->pproverride_URL; 2256 2256 } else { 2257 2257 $urlsite = $this->ppr_metaurl; 2258 2258 } 2259 $this->pproverride_URL = ''; //reset2260 if($this->pprmeta_seconds==''){2259 $this->pproverride_URL = ''; //reset 2260 if($this->pprmeta_seconds==''){ 2261 2261 $this->pprmeta_seconds='0'; 2262 2262 } … … 2629 2629 return sanitize_title_with_dashes( 'browser-'.$name ); 2630 2630 } 2631 2632 function qppr_sanitize_option_redirects( $value ) { 2633 $new_value = []; 2634 2635 foreach ( $value as $url_from => $url_to ) { 2636 $new_value[esc_url($url_from)] = esc_url($url_to); 2637 } 2638 2639 return $new_value; 2640 } 2641 add_filter( 'sanitize_option_quickppr_redirects', 'qppr_sanitize_option_redirects', 10, 1 ); 2642 2643 function qppr_sanitize_option_redirects_meta( $value ) { 2644 $new_value = []; 2645 2646 foreach ( $value as $url => $meta ) { 2647 $new_value[$url] = array( 2648 'newwindow' => absint( $meta['newwindow'] ), 2649 'nofollow' => absint( $meta['newwindow'] ), 2650 ); 2651 } 2652 2653 return $new_value; 2654 } 2655 add_filter( 'sanitize_option_quickppr_redirects_meta', 'qppr_sanitize_option_redirects_meta', 10, 1 ); 2656 2657 function qppr_sanitize_pprredirect_active_meta( $meta_value ) { 2658 return absint( $meta_value ); 2659 } 2660 add_filter( 'sanitize_post_meta__pprredirect_active', 'qppr_sanitize_pprredirect_active_meta', 10, 1 ); 2661 2662 function qppr_sanitize_pprredirect_newwindow_meta( $meta_value ) { 2663 return sanitize_text_field( $meta_value ); 2664 } 2665 add_filter( 'sanitize_post_meta__pprredirect_newwindow', 'qppr_sanitize_pprredirect_newwindow_meta', 10, 1 ); 2666 2667 function qppr_sanitize_pprredirect_relnofollow_meta( $meta_value ) { 2668 return absint( $meta_value ); 2669 } 2670 add_filter( 'sanitize_post_meta__pprredirect_relnofollow', 'qppr_sanitize_pprredirect_relnofollow_meta', 10, 1 ); 2671 2672 function qppr_sanitize_pprredirect_rewritelink_meta( $meta_value ) { 2673 return absint( $meta_value ); 2674 } 2675 add_filter( 'sanitize_post_meta__pprredirect_rewritelink', 'qppr_sanitize_pprredirect_rewritelink_meta', 10, 1 ); 2676 2677 function qppr_sanitize_pprredirect_type_meta( $meta_value ) { 2678 if ( $meta_value != 'meta' ) { 2679 return absint( $meta_value ); 2680 } 2681 2682 return sanitize_text_field( $meta_value ); 2683 } 2684 add_filter( 'sanitize_post_meta__pprredirect_type', 'qppr_sanitize_pprredirect_type_meta', 10, 1 );
Note: See TracChangeset
for help on using the changeset viewer.