コード例 #1
0
 /**
  * Adds the meta boxes required to manage ad layers on posts.
  * @access public
  */
 public function add_meta_boxes()
 {
     // Get the post type name
     $post_type = str_replace('fm_post_', '', current_filter());
     // Add ad units
     $fm_ad_layer = new Fieldmanager_Autocomplete(array('name' => 'ad_layer', 'description' => __('Select a specific custom ad layer to use with this post.', 'ad-layers'), 'datasource' => new Fieldmanager_Datasource_Post(array('query_args' => array('post_type' => array(Ad_Layers_Post_Type::instance()->get_post_type()), 'post_status' => 'publish', 'order_by' => 'title')))));
     $fm_ad_layer->add_meta_box(__('Ad Layer', 'ad-layers'), $post_type, 'side', 'core');
 }
コード例 #2
0
 /**
  * Get the available page types for all ad servers.
  * These are especially used by path targeting.
  * This is kind of expensive so make sure we only do it once.
  * @access public
  * @return array
  */
 public function get_page_types()
 {
     if (empty($this->page_types)) {
         // Build the page types.
         // First add global types.
         $page_types = array('home' => __('Home Page', 'ad-layers'));
         // Add single post types
         $single_post_types = apply_filters('ad_layers_ad_server_single_post_types', wp_list_filter(get_post_types(array('public' => true), 'objects'), array('label' => false), 'NOT'));
         if (!empty($single_post_types)) {
             foreach ($single_post_types as $post_type) {
                 if (Ad_Layers_Post_Type::instance()->get_post_type() != $post_type->name) {
                     $page_types[$post_type->name] = $post_type->label;
                 }
             }
         }
         // Add archived post types
         $archived_post_types = apply_filters('ad_layers_ad_server_archived_post_types', wp_list_filter(get_post_types(array('has_archive' => true), 'objects'), array('label' => false), 'NOT'));
         if (!empty($archived_post_types)) {
             foreach ($archived_post_types as $post_type) {
                 $page_types['archive::' . $post_type->name] = $post_type->label . __(' Archive', 'ad-layers');
             }
         }
         // Add taxonomies
         $taxonomies = apply_filters('ad_layers_ad_server_taxonomies', wp_list_filter(get_taxonomies(array('public' => true), 'objects'), array('label' => false), 'NOT'));
         if (!empty($taxonomies)) {
             foreach ($taxonomies as $taxonomy) {
                 $page_types[$taxonomy->name] = $taxonomy->label . __(' Archive', 'ad-layers');
             }
         }
         // Add some other templates at the bottom
         $page_types = array_merge($page_types, array('author' => __('Author Archive', 'ad-layers'), 'date' => __('Date Archive', 'ad-layers'), 'notfound' => __('404 Page', 'ad-layers'), 'search' => __('Search Results', 'ad-layers'), 'default' => __('Default', 'ad-layers')));
         $this->page_types = $page_types;
     }
     return apply_filters('ad_layers_page_types', $this->page_types);
 }
コード例 #3
0
 /**
  * Setup the singleton.
  */
 public function setup()
 {
     // Define the available formatting tags
     $this->formatting_tags = apply_filters('ad_layers_dfp_formatting_tags', $this->set_formatting_tags());
     // Allow filtering of the ad unit prefix
     $this->ad_unit_prefix = apply_filters('ad_layers_dfp_ad_unit_prefix', $this->ad_unit_prefix);
     // Add a help tab
     add_action('load-' . Ad_Layers_Post_Type::instance()->get_post_type() . '_page_' . $this->option_name, array($this, 'add_help_tab'));
     // Handle caching
     add_action('update_option', array($this, 'cache_settings'), 10, 3);
     // Add the path override field to the ad layer ad units
     add_filter('ad_layers_ad_units_field_args', array($this, 'ad_layer_path_overrides'));
 }
コード例 #4
0
         * Get the human-readable names for given post types.
         *
         * This is a helper for custom column values, so the user sees e.g.
         * "My Custom Posts" instead of "my-custom-posts".
         *
         * @param  array $post_types Post type slugs.
         * @return array Post type names.
         */
        public function get_post_type_names($post_types)
        {
            if (empty($post_types)) {
                return array();
            }
            foreach ((array) $post_types as $i => $post_type) {
                $post_type_obj = get_post_type_object($post_type);
                $post_types[$i] = $post_type_obj->labels->name;
            }
            return $post_types;
        }
        /**
         * Output an array as an unordered list for custom columns.
         *
         * @param  array $array The array to output.
         */
        protected function column_listify($array)
        {
            echo '<ul class="ad-layers-column-list"><li>' . implode('</li><li>', array_map('esc_html', $array)) . '</li></ul>';
        }
    }
    Ad_Layers_Post_Type::instance();
}