Plugin Directory

Changeset 2457799


Ignore:
Timestamp:
01/17/2021 11:39:13 AM (5 years ago)
Author:
anadnet
Message:

Sanitizing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quick-pagepost-redirect-plugin/trunk/page_post_redirect_plugin.php

    r2449356 r2457799  
    104104        add_action( 'admin_init', array( $this, 'ppr_init_check_version' ), 1 );                                // checks version of plugin in DB and updates if needed.
    105105        add_action( 'admin_init', array( $this, 'qppr_meta_plugin_has_addon' ) );
    106         add_action( 'init', array( $this, 'ppr_parse_request_new' ) );                                          // parse query vars
     106            add_action( 'init', array( $this, 'ppr_parse_request_new' ) );                                          // parse query vars
    107107        add_action( 'save_post', array( $this,'ppr_save_metadata' ), 11, 2 );                                   // save the custom fields
    108108        add_action( 'admin_menu', array( $this,'ppr_add_menu_and_metaboxes' ) );                                // add the menu items & Metaboxes needed
     
    177177        // make sure the function is present
    178178        if ( ! function_exists('is_plugin_active'))
    179             require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
     179                require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    180180
    181181        // WP Super Cache
     
    753753        echo '
    754754        <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>
    756756            <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>
    757757            <hr noshade color="#C0C0C0" size="1" />
     
    761761        $linkcontent    = array();
    762762        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 );
    765765        endif;
    766766            $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 &uarr;</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 &uarr;</a></li>';
     772                    endforeach;
    773773            }
    774774        echo '<a name="faq-top"></a><h2>'.__('Table of Contents','quick-pagepost-redirect-plugin').'</h2>';
     
    929929            }
    930930         ?>
    931             </tbody>
     931            </tbody>
    932932        </table>
    933933    </div>
     
    12101210            ';
    12111211            $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 ,
    12151215            ) );
    12161216            $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;">
    12211221                <b style="color:red;">' . __( 'IMPORTANT TROUBLESHOOTING NOTES:', 'quick-pagepost-redirect-plugin' ) . '</b>
    12221222                <ol style="margin-top:5px;">
     
    12381238        }elseif( $screen_id == 'quick-redirects_page_redirect-import-export' ){
    12391239            $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>' ,
    12431243            ) );
    12441244            $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>' ,
    12481248            ) );
    12491249        }elseif( $screen_id == 'quick-redirects_page_meta_addon' ){
    12501250            $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>' ,
    12551255            ) );
    12561256            $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>' ,
    12611261            ) );
    12621262            $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 "&lt;" or "&gt;" characters in the name, i.e., &lt;body&gt; 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 "&lt;" or "&gt;" characters in the name, i.e., &lt;body&gt; 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>' ,
    12701270            ) );
    12711271            $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>' ,
    12771277            ) );
    12781278            $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>' ,
    12841284            ) );
    12851285        }
     
    22522252        $hook_name  = 'ppr_meta_head_hook';
    22532253        // check URL override
    2254         if($this->pproverride_URL !=''){
     2254            if($this->pproverride_URL !=''){
    22552255            $urlsite = $this->pproverride_URL;
    22562256        } else {
    22572257            $urlsite = $this->ppr_metaurl;
    22582258        }
    2259         $this->pproverride_URL = ''; //reset
    2260         if($this->pprmeta_seconds==''){
     2259            $this->pproverride_URL = ''; //reset
     2260            if($this->pprmeta_seconds==''){
    22612261            $this->pprmeta_seconds='0';
    22622262        }
     
    26292629    return sanitize_title_with_dashes( 'browser-'.$name );
    26302630}
     2631
     2632function 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}
     2641add_filter( 'sanitize_option_quickppr_redirects', 'qppr_sanitize_option_redirects', 10, 1 );
     2642
     2643function 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}
     2655add_filter( 'sanitize_option_quickppr_redirects_meta', 'qppr_sanitize_option_redirects_meta', 10, 1 );
     2656
     2657function qppr_sanitize_pprredirect_active_meta( $meta_value ) {
     2658    return absint( $meta_value );
     2659}
     2660add_filter( 'sanitize_post_meta__pprredirect_active', 'qppr_sanitize_pprredirect_active_meta', 10, 1 );
     2661
     2662function qppr_sanitize_pprredirect_newwindow_meta( $meta_value ) {
     2663    return sanitize_text_field( $meta_value );
     2664}
     2665add_filter( 'sanitize_post_meta__pprredirect_newwindow', 'qppr_sanitize_pprredirect_newwindow_meta', 10, 1 );
     2666
     2667function qppr_sanitize_pprredirect_relnofollow_meta( $meta_value ) {
     2668    return absint( $meta_value );
     2669}
     2670add_filter( 'sanitize_post_meta__pprredirect_relnofollow', 'qppr_sanitize_pprredirect_relnofollow_meta', 10, 1 );
     2671
     2672function qppr_sanitize_pprredirect_rewritelink_meta( $meta_value ) {
     2673    return absint( $meta_value );
     2674}
     2675add_filter( 'sanitize_post_meta__pprredirect_rewritelink', 'qppr_sanitize_pprredirect_rewritelink_meta', 10, 1 );
     2676
     2677function 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}
     2684add_filter( 'sanitize_post_meta__pprredirect_type', 'qppr_sanitize_pprredirect_type_meta', 10, 1 );
Note: See TracChangeset for help on using the changeset viewer.