Code Duplication    Length = 7-21 lines in 2 locations

core/EE_Front_Controller.core.php 1 location

@@ 254-274 (lines=21) @@
251
            $this->Request_Handler->get('post_name'));
252
        $show_on_front = get_option('show_on_front');
253
        // if it's not set, then check if frontpage is blog
254
        if (empty($current_post)) {
255
            // yup.. this is the posts page, prepare to load all shortcode modules
256
            $current_post = 'posts';
257
            // unless..
258
            if ($show_on_front === 'page') {
259
                // some other page is set as the homepage
260
                $page_on_front = get_option('page_on_front');
261
                if ($page_on_front) {
262
                    // k now we need to find the post_name for this page
263
                    global $wpdb;
264
                    $page_on_front = $wpdb->get_var(
265
                        $wpdb->prepare(
266
                            "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d",
267
                            $page_on_front
268
                        )
269
                    );
270
                    // set the current post slug to what it actually is
271
                    $current_post = $page_on_front ? $page_on_front : $current_post;
272
                }
273
            }
274
        }
275
        // where are posts being displayed ?
276
        $page_for_posts = EE_Config::get_page_for_posts();
277
        // in case $current_post is hierarchical like: /parent-page/current-page

core/admin/PostShortcodeTracking.php 1 location

@@ 393-399 (lines=7) @@
390
     */
391
    public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' )
392
    {
393
        if ( $option === 'page_for_posts' ) {
394
            global $wpdb;
395
            $table = $wpdb->posts;
396
            $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
397
            $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts';
398
            PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts );
399
        }
400
    }
401
402