public function restore_missing_pages()
 {
     $shortcodes = awpcp_pages();
     $missing_pages = $this->missing_pages_finder->find_missing_pages();
     $pages_to_restore = array_merge($missing_pages['not-found'], $missing_pages['not-referenced']);
     $page_refs = awpcp_get_properties($pages_to_restore, 'page');
     // If we are restoring the main page, let's do it first!
     if (($p = array_search('main-page-name', $page_refs)) !== FALSE) {
         // put the main page as the first page to restore
         array_splice($pages_to_restore, 0, 0, array($pages_to_restore[$p]));
         array_splice($pages_to_restore, $p + 1, 1);
     }
     $restored_pages = array();
     foreach ($pages_to_restore as $page) {
         $refname = $page->page;
         $name = get_awpcp_option($refname);
         if (strcmp($refname, 'main-page-name') == 0) {
             awpcp_create_pages($name, $subpages = false);
         } else {
             awpcp_create_subpage($refname, $name, $shortcodes[$refname][1]);
         }
         $restored_pages[] = $page;
     }
     update_option('awpcp-flush-rewrite-rules', true);
     return $restored_pages;
 }
 /**
  * Renders an HTML page with AWPCP informaiton useful for debugging tasks.
  *
  * @since 2.0.7
  */
 private function render($download = false)
 {
     global $awpcp, $wpdb, $wp_rewrite;
     $debug_info = $this;
     $options = $awpcp->settings->options;
     $options['awpcp_installationcomplete'] = get_option('awpcp_installationcomplete');
     $options['awpcp_pagename_warning'] = get_option('awpcp_pagename_warning');
     $options['widget_awpcplatestads'] = get_option('widget_awpcplatestads');
     $options['awpcp_db_version'] = get_option('awpcp_db_version');
     $plugin_pages_info = awpcp_get_plugin_pages_info();
     $page_objects = get_pages(array('include' => awpcp_get_properties($plugin_pages_info, 'page_id', 0)));
     $plugin_pages = array();
     foreach ($page_objects as $page) {
         $plugin_pages[$page->ID] = $page;
     }
     $rules = (array) $wp_rewrite->wp_rewrite_rules();
     ob_start();
     include AWPCP_DIR . '/admin/templates/admin-panel-debug.tpl.php';
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
			<div class="metabox-holder">
				<div class="postbox">
					<h3 class="hndle"><span><?php 
_e('Restore AWPCP Pages', 'AWPCP');
?>
</span></h3>
					<div class="inside">

			<?php 
if (!empty($restored_pages)) {
    $message = __('The following pages were restored: <pages-list>.', 'AWPCP');
    $pages_names = array_map('awpcp_get_option', awpcp_get_properties($restored_pages, 'page'));
    $pages_list = '<strong>' . implode('</strong>, <strong>', $pages_names) . '</strong>';
    echo awpcp_print_message(str_replace('<pages-list>', $pages_list, $message));
}
?>

			<?php 
if (!empty($missing)) {
    ?>

			<div class="error">
			<?php 
    if (!empty($missing['not-found'])) {
        ?>
				<p><?php 
        _e("The following pages are missing; the plugin is looking for a page with a particular ID but it seems that the page was permanently deleted.", 'AWPCP');
        ?>
</p>

				<ul>
Exemple #4
0
 public function random_listings_shortcode($attrs)
 {
     wp_enqueue_script('awpcp');
     $attrs = shortcode_atts(array('menu' => true, 'limit' => 10), $attrs);
     $show_menu = awpcp_parse_bool($attrs['menu']);
     $limit = absint($attrs['limit']);
     $random_query = array('context' => 'public-listings', 'fields' => 'ad_id', 'raw' => true);
     $random_listings = awpcp_listings_collection()->find_enabled_listings_with_query($random_query);
     $random_listings_ids = awpcp_get_properties($random_listings, 'ad_id');
     shuffle($random_listings_ids);
     $query = array('id' => array_slice($random_listings_ids, 0, $limit), 'limit' => $limit);
     $options = array('show_menu_items' => $show_menu);
     return awpcp_display_listings($query, 'random-listings-shortcode', $options);
 }
 function x_fields_fetch_fields()
 {
     $fields = awpcp_get_extra_fields();
     return awpcp_get_properties($fields, 'field_name');
 }
Exemple #6
0
 public static function get_random_ads($limit, $args = array(), $conditions = array())
 {
     $conditions = self::get_where_conditions($conditions);
     $tmpargs = array_merge($args, array('fields' => 'ad_id', 'limit' => 0, 'offset' => 0));
     $results = self::query(array_merge($tmpargs, array('where' => join(' AND ', $conditions))), true);
     $random_ids = awpcp_get_properties($results, 'ad_id');
     shuffle($random_ids);
     $random_ids = array_slice($random_ids, 0, $limit);
     if ($random_ids) {
         $conditions[] = 'ad_id IN (' . join(',', $random_ids) . ')';
     }
     $args = array_merge($args, array('limit' => 0, 'offset' => 0));
     return self::get_enabled_ads($args, $conditions);
 }
Exemple #7
0
/**
 * @since 3.0
 */
function awpcp_get_comma_separated_categories_list($categories = array(), $threshold = 5)
{
    $names = awpcp_get_properties($categories, 'name');
    return awpcp_get_comma_separated_list($names, $threshold, __('None', 'AWPCP'));
}