protected function do_file_action($file, $listing)
 {
     $enabled_status = awpcp_parse_bool($this->request->post('new_status'));
     if ($enabled_status) {
         return $this->media->enable($file);
     } else {
         return $this->media->disable($file);
     }
 }
 private function render_shortcode_content($attrs)
 {
     extract($attrs);
     $category = $id > 0 ? AWPCP_Category::find_by_id($id) : null;
     $children = awpcp_parse_bool($children);
     if (is_null($category)) {
         return __('Category ID must be valid for Ads to display.', 'category shortcode', 'AWPCP');
     }
     if ($children) {
         $categories_list = awpcp_categories_list_renderer()->render(array('parent_category_id' => $category->id, 'show_listings_count' => true));
         $options = array('before_pagination' => array(10 => array('categories-list' => $categories_list)));
     } else {
         $options = array();
     }
     $query = array('context' => 'public-listings', 'category_id' => $category->id, 'include_listings_in_children_categories' => $children, 'limit' => absint($this->request->param('results', $items_per_page)), 'offset' => absint($this->request->param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby'));
     // required so awpcp_display_ads shows the name of the current category
     $_REQUEST['category_id'] = $category->id;
     return awpcp_display_listings_in_page($query, 'category-shortcode', $options);
 }
 public function render()
 {
     $option_name = 'hide-all-payment-terms-if-no-category-is-selected';
     awpcp()->js->set($option_name, awpcp_parse_bool(get_awpcp_option($option_name)));
     ob_start();
     include AWPCP_DIR . '/frontend/templates/payments-payment-terms-table.tpl.php';
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Beispiel #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);
 }