private function upgrade_to_3_5_3($oldversion) { global $wpdb; $plugin_pages = awpcp_get_plugin_pages_info(); if (empty($plugin_pages)) { // move plugin pages info from PAGES table to awpcp-plugin-pages option $pages = $wpdb->get_results('SELECT page, id FROM ' . AWPCP_TABLE_PAGES, OBJECT_K); foreach ($pages as $page_ref => $page_info) { awpcp_update_plugin_page_id($page_ref, $page_info->id); } } // make sure there are entries for 'view-categories-page-name' in the plugin pages info $plugin_pages = awpcp_get_plugin_pages_info(); if (isset($plugin_pages['view-categories-page-name'])) { unset($plugin_pages['view-categories-page-name']); awpcp_update_plugin_pages_info($plugin_pages); } // drop no longer used PAGENAME table $wpdb->query('DROP TABLE IF EXISTS ' . AWPCP_TABLE_PAGENAME); }
/** * Creates a subpage of the main AWPCP page. * * This functions takes care of checking if the main AWPCP * page exists, finding its id and verifying that the new * page doesn't exist already. Useful for module plugins. */ function awpcp_create_subpage($refname, $name, $shortcode, $awpcp_page_id = null) { global $wpdb; $id = 0; if (!empty($name)) { // it is possible that the main AWPCP page does not exist, in that case // we should create Subpages without a parent. if (is_null($awpcp_page_id) && awpcp_find_page('main-page-name')) { $awpcp_page_id = awpcp_get_page_id_by_ref('main-page-name'); } else { if (is_null($awpcp_page_id)) { $awpcp_page_id = ''; } } if (!awpcp_find_page($refname)) { $id = maketheclassifiedsubpage($name, $awpcp_page_id, $shortcode); } } if ($id > 0) { awpcp_update_plugin_page_id($refname, $id); } return $id; }