function awpcp_general_settings()
{
    return new AWPCP_GeneralSettings(awpcp_roles_and_capabilities());
}
function awpcp_listing_authorization()
{
    return new AWPCP_ListingAuthorization(awpcp_roles_and_capabilities(), awpcp_request());
}
Example #3
0
 public function init()
 {
     // load resources always required
     $facebook_cache_helper = awpcp_facebook_cache_helper();
     add_action('awpcp-clear-ad-facebook-cache', array($facebook_cache_helper, 'handle_clear_cache_event_hook'), 10, 1);
     $send_new_listings_to_facebook_helper = awpcp_send_listing_to_facebook_helper();
     add_action('awpcp-listing-facebook-cache-cleared', array($send_new_listings_to_facebook_helper, 'schedule_listing_if_necessary'));
     add_action('awpcp-send-listing-to-facebook', array($send_new_listings_to_facebook_helper, 'send_listing_to_facebook'));
     add_action('awpcp-place-ad', array($this, 'clear_categories_list_cache'));
     add_action('awpcp_approve_ad', array($this, 'clear_categories_list_cache'));
     add_action('awpcp_edit_ad', array($this, 'clear_categories_list_cache'));
     add_action('awpcp_disable_ad', array($this, 'clear_categories_list_cache'));
     add_action('awpcp_delete_ad', array($this, 'clear_categories_list_cache'));
     add_action('awpcp-category-added', array($this, 'clear_categories_list_cache'));
     add_action('awpcp-category-edited', array($this, 'clear_categories_list_cache'));
     add_action('awpcp-category-deleted', array($this, 'clear_categories_list_cache'));
     add_action('awpcp-pages-updated', array($this, 'clear_categories_list_cache'));
     add_action('awpcp-listings-imported', array($this, 'clear_categories_list_cache'));
     add_filter('awpcp-listing-actions', array($this, 'register_listing_actions'), 10, 2);
     // load resources required both in front end and admin screens, but not during ajax calls.
     if (!defined('DOING_AJAX') || !DOING_AJAX) {
         $listing_payment_transaction_handler = awpcp_listing_payment_transaction_handler();
         add_action('awpcp-transaction-status-updated', array($listing_payment_transaction_handler, 'transaction_status_updated'), 10, 2);
         add_filter('awpcp-process-payment-transaction', array($listing_payment_transaction_handler, 'process_payment_transaction'));
         add_action('awpcp-place-ad', array($facebook_cache_helper, 'on_place_ad'));
         add_action('awpcp_approve_ad', array($facebook_cache_helper, 'on_approve_ad'));
         add_action('awpcp_edit_ad', array($facebook_cache_helper, 'on_edit_ad'));
     }
     if (defined('DOING_CRON') && DOING_CRON) {
         $task_queue = awpcp_task_queue();
         add_action('awpcp-task-queue-event', array($task_queue, 'task_queue_event'));
         add_action('awpcp-task-queue-cron', array($task_queue, 'task_queue_event'));
     } else {
         if (defined('DOING_AJAX') && DOING_AJAX) {
             $this->ajax_setup();
         } else {
             if (is_admin()) {
                 // load resources required in admin screens only
                 $controller = awpcp_user_profile_contact_information_controller();
                 add_action('show_user_profile', array($controller, 'show_contact_information_fields'));
                 add_action('edit_user_profile', array($controller, 'show_contact_information_fields'));
                 add_action('personal_options_update', array($controller, 'save_contact_information'));
                 add_action('edit_user_profile_update', array($controller, 'save_contact_information'));
                 $monitor = awpcp_page_name_monitor();
                 add_action('post_updated', array($monitor, 'flush_rewrite_rules_if_plugin_pages_name_changes'), 10, 3);
                 $pointers_manager = awpcp_pointers_manager();
                 add_action('admin_enqueue_scripts', array($pointers_manager, 'register_pointers'));
                 add_action('admin_enqueue_scripts', array($pointers_manager, 'setup_pointers'));
                 if (awpcp_current_user_is_admin()) {
                     // load resources required in admin screens only, visible to admin users only.
                     add_action('admin_notices', array(awpcp_fee_payment_terms_notices(), 'dispatch'));
                     add_action('admin_notices', array(awpcp_credit_plans_notices(), 'dispatch'));
                     $handler = awpcp_update_license_status_request_handler();
                     add_action('admin_init', array($handler, 'dispatch'));
                 } else {
                     // load resources required in admin screens only, visible to non-admin users only.
                 }
             } else {
                 // load resources required in frontend screens only.
                 add_action('template_redirect', array(new AWPCP_SecureURLRedirectionHandler(), 'dispatch'));
             }
         }
     }
     add_filter('awpcp-content-placeholders', array($this, 'register_content_placeholders'));
     $listing_form_fields = awpcp_listing_form_fields();
     add_filter('awpcp-form-fields', array($listing_form_fields, 'register_listing_form_fields'), 5, 1);
     if (!get_option('awpcp_installationcomplete', 0)) {
         update_option('awpcp_installationcomplete', 1);
         awpcp_create_pages(__('AWPCP', 'AWPCP'));
         $this->flush_rewrite_rules = true;
     }
     if (get_option('awpcp-enable-fix-media-mime-type-upgrde')) {
         awpcp_fix_empty_media_mime_type_upgrade_routine()->run();
     }
     if ($this->flush_rewrite_rules || get_option('awpcp-flush-rewrite-rules')) {
         add_action('wp_loaded', 'flush_rewrite_rules');
         update_option('awpcp-flush-rewrite-rules', false);
     }
     if (get_option('awpcp-installed-or-upgraded')) {
         $roles_and_capabilities = awpcp_roles_and_capabilities();
         add_action('wp_loaded', array($roles_and_capabilities, 'setup_roles_capabilities'));
         delete_option('awpcp-installed-or-upgraded');
     }
     $this->register_scripts();
     $this->register_notification_handlers();
 }
Example #4
0
function awpcp_user_is_admin($id)
{
    return awpcp_roles_and_capabilities()->user_is_administrator($id);
}