1 <?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' ); |
|
2 /** |
|
3 * OptionTree Post Formats API |
|
4 * |
|
5 * This class loads all the methods and helpers specific to build a the post format metaboxes. |
|
6 * |
|
7 * @package OptionTree |
|
8 * @author Derek Herman <derek@valendesigns.com> |
|
9 * @copyright Copyright (c) 2014, Derek Herman |
|
10 */ |
|
11 if ( ! class_exists( 'OT_Post_Formats' ) ) { |
|
12 |
|
13 class OT_Post_Formats { |
|
14 |
|
15 /** |
|
16 * Class Constructor |
|
17 * |
|
18 * @return void |
|
19 * |
|
20 * @access public |
|
21 * @since 2.3.0 |
|
22 */ |
|
23 public function __construct() { |
|
24 |
|
25 $this->setup_actions(); |
|
26 |
|
27 } |
|
28 |
|
29 /** |
|
30 * Setup the default filters and actions |
|
31 * |
|
32 * @uses add_action() To add various actions |
|
33 * @uses add_filter() To add various filters |
|
34 * |
|
35 * @return void |
|
36 * |
|
37 * @access private |
|
38 * @since 2.3.0 |
|
39 */ |
|
40 private function setup_actions() { |
|
41 |
|
42 // Initialize the meta boxes |
|
43 add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 ); |
|
44 |
|
45 // Setup pings for the link & quote URLs |
|
46 add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 ); |
|
47 |
|
48 } |
|
49 |
|
50 /** |
|
51 * Builds the default Meta Boxes. |
|
52 * |
|
53 * @return void |
|
54 * |
|
55 * @access private |
|
56 * @since 2.3.0 |
|
57 */ |
|
58 public function meta_boxes() { |
|
59 |
|
60 // Exit if called outside of WP admin |
|
61 if ( ! is_admin() ) |
|
62 return false; |
|
63 |
|
64 /** |
|
65 * Filter the post formats meta boxes. |
|
66 * |
|
67 * @since 2.6.0 |
|
68 * |
|
69 * @param array $meta_boxes The meta boxes being registered. |
|
70 * @return array |
|
71 */ |
|
72 $meta_boxes = apply_filters( 'ot_recognized_post_format_meta_boxes', array( |
|
73 ot_meta_box_post_format_gallery(), |
|
74 ot_meta_box_post_format_link(), |
|
75 ot_meta_box_post_format_quote(), |
|
76 ot_meta_box_post_format_video(), |
|
77 ot_meta_box_post_format_audio(), |
|
78 ) ); |
|
79 |
|
80 /** |
|
81 * Register our meta boxes using the |
|
82 * ot_register_meta_box() function. |
|
83 */ |
|
84 foreach( $meta_boxes as $meta_box ) { |
|
85 |
|
86 ot_register_meta_box( $meta_box ); |
|
87 |
|
88 } |
|
89 |
|
90 } |
|
91 |
|
92 /** |
|
93 * Setup pings for the link & quote URLs |
|
94 * |
|
95 * @param array $post_links The URLs to ping |
|
96 * @param array $pung Pinged URLs |
|
97 * @param int $post_id Post ID |
|
98 * @return array |
|
99 * |
|
100 * @access public |
|
101 * @since 2.3.0 |
|
102 */ |
|
103 public function pre_ping_post_links( $post_links, $pung, $post_id = null ) { |
|
104 |
|
105 $_link = get_post_meta( $post_id, '_format_link_url', true ); |
|
106 if ( ! empty( $_link ) && ! in_array( $_link, $pung ) && ! in_array( $_link, $post_links ) ) |
|
107 $post_links[] = $_link; |
|
108 |
|
109 $_quote = get_post_meta( $post_id, '_format_quote_source_url', true ); |
|
110 if ( ! empty( $_quote ) && ! in_array( $_quote, $pung ) && ! in_array( $_quote, $post_links ) ) |
|
111 $post_links[] = $_quote; |
|
112 |
|
113 } |
|
114 |
|
115 } |
|
116 |
|
117 } |
|
118 |
|
119 /** |
|
120 * Instantiate The Class |
|
121 * |
|
122 * @since 1.0 |
|
123 */ |
|
124 if ( function_exists( 'ot_register_meta_box' ) ) { |
|
125 |
|
126 new OT_Post_Formats(); |
|
127 |
|
128 } |
|
129 |
|
130 /* End of file ot-post-formats-api.php */ |
|
131 /* Location: ./includes/ot-post-formats-api.php */ |
|