|
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 $meta_boxes = array( |
|
65 ot_meta_box_post_format_gallery(), |
|
66 ot_meta_box_post_format_link(), |
|
67 ot_meta_box_post_format_quote(), |
|
68 ot_meta_box_post_format_video(), |
|
69 ot_meta_box_post_format_audio() |
|
70 ); |
|
71 |
|
72 /** |
|
73 * Register our meta boxes using the |
|
74 * ot_register_meta_box() function. |
|
75 */ |
|
76 foreach( $meta_boxes as $meta_box ) { |
|
77 |
|
78 ot_register_meta_box( $meta_box ); |
|
79 |
|
80 } |
|
81 |
|
82 } |
|
83 |
|
84 /** |
|
85 * Setup pings for the link & quote URLs |
|
86 * |
|
87 * @param array $post_links The URLs to ping |
|
88 * @param array $pung Pinged URLs |
|
89 * @param int $post_id Post ID |
|
90 * @return array |
|
91 * |
|
92 * @access public |
|
93 * @since 2.3.0 |
|
94 */ |
|
95 public function pre_ping_post_links( $post_links, $pung, $post_id = null ) { |
|
96 |
|
97 $_link = get_post_meta( $post_id, '_format_link_url', true ); |
|
98 if ( ! empty( $_link ) && ! in_array( $_link, $pung ) && ! in_array( $_link, $post_links ) ) |
|
99 $post_links[] = $_link; |
|
100 |
|
101 $_quote = get_post_meta( $post_id, '_format_quote_source_url', true ); |
|
102 if ( ! empty( $_quote ) && ! in_array( $_quote, $pung ) && ! in_array( $_quote, $post_links ) ) |
|
103 $post_links[] = $_quote; |
|
104 |
|
105 } |
|
106 |
|
107 } |
|
108 |
|
109 } |
|
110 |
|
111 /** |
|
112 * Instantiate The Class |
|
113 * |
|
114 * @since 1.0 |
|
115 */ |
|
116 if ( function_exists( 'ot_register_meta_box' ) ) { |
|
117 |
|
118 new OT_Post_Formats(); |
|
119 |
|
120 } |
|
121 |
|
122 /* End of file ot-post-formats-api.php */ |
|
123 /* Location: ./includes/ot-post-formats-api.php */ |