public function find_missing_pages() { $plugin_pages = awpcp_get_plugin_pages_info(); $registered_pages = array_keys(awpcp_pages()); $referenced_pages = array_keys($plugin_pages); // pages that are registered in the code but no referenced in the DB $pages_not_referenced = array_diff($registered_pages, $referenced_pages); $registered_pages_ids = awpcp_get_page_ids_by_ref($registered_pages); $query = 'SELECT posts.ID post, posts.post_status status '; $query .= 'FROM ' . $this->db->posts . ' AS posts '; $query .= "WHERE posts.ID IN (" . join(",", $registered_pages_ids) . ") "; $existing_pages = $this->db->get_results($query, OBJECT_K); $missing_pages = array('not-found' => array(), 'not-published' => array(), 'not-referenced' => array()); foreach ($plugin_pages as $page_ref => $page_info) { $page = isset($existing_pages[$page_info['page_id']]) ? $existing_pages[$page_info['page_id']] : null; if (is_object($page) && isset($page->status) && $page->status != 'publish') { $page->page = $page_ref; $page->id = $page_info['page_id']; $missing_pages['not-published'][] = $page; } else { if (is_null($page)) { $page = new stdClass(); $page->page = $page_ref; $page->id = $page_info['page_id']; $page->post = null; $page->status = null; $missing_pages['not-found'][] = $page; } } } // if a page is registered in the code but there is no reference of it // in the database, include a dummy object to represent it. foreach ($pages_not_referenced as $page) { $item = new stdClass(); $item->page = $page; $item->id = null; $item->post = null; $item->status = null; $missing_pages['not-referenced'][] = $item; } return $missing_pages; }
/** * Overwrittes WP canonicalisation to ensure our rewrite rules * work, even when the main AWPCP page is also the front page or * when the requested page slug is 'awpcp'. * * Required for the View Categories and Classifieds RSS rules to work * when AWPCP main page is also the front page. * * http://wordpress.stackexchange.com/questions/51530/rewrite-rules-problem-when-rule-includes-homepage-slug */ function awpcp_redirect_canonical($redirect_url, $requested_url) { global $wp_query; $awpcp_rewrite = false; $ids = awpcp_get_page_ids_by_ref(awpcp_pages_with_rewrite_rules()); // do not redirect requests to AWPCP pages with rewrite rules if (is_page() && in_array(awpcp_request_param('page_id', 0), $ids)) { $awpcp_rewrite = true; // do not redirect requests to the front page, if any of the AWPCP pages // with rewrite rules is the front page } else { if (is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && in_array($wp_query->queried_object->ID, $ids) && $wp_query->queried_object->ID == get_option('page_on_front')) { $awpcp_rewrite = true; } } if ($awpcp_rewrite) { // Fix for #943. $requested_host = parse_url($requested_url, PHP_URL_HOST); $redirect_host = parse_url($redirect_url, PHP_URL_HOST); if ($requested_host != $redirect_host) { if (strtolower($redirect_host) == 'www.' . $requested_host) { return str_replace($requested_host, 'www.' . $requested_host, $requested_url); } elseif (strtolower($requested_host) == 'www.' . $redirect_host) { return str_replace('www.', '', $requested_url); } } return $requested_url; } // $id = awpcp_get_page_id_by_ref('main-page-name'); // // do not redirect direct requests to AWPCP main page // if (is_page() && !empty($_GET['page_id']) && $id == $_GET['page_id']) { // $redirect_url = $requested_url; // // do not redirect request to the front page, if AWPCP main page is // // the front page // } else if (is_page() && !is_feed() && isset($wp_query->queried_object) && // 'page' == get_option('show_on_front') && $id == $wp_query->queried_object->ID && // $wp_query->queried_object->ID == get_option('page_on_front')) // { // $redirect_url = $requested_url; // } return $redirect_url; }
function awpcp_cryptx_compatibility() { awpcp_cryptx_exclude_posts(awpcp_get_page_ids_by_ref(array('place-ad-page-name', 'edit-ad-page-name', 'reply-to-ad-page-name'))); }