|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Black Studio TinyMCE Widget - Compatibility with WordPress versions prior to 3.5 |
|
4
|
|
|
* |
|
5
|
|
|
* @package Black_Studio_TinyMCE_Widget |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Black_Studio_TinyMCE_Widget\Compatibility\WordPress; |
|
9
|
|
|
|
|
10
|
|
|
// Exit if accessed directly. |
|
11
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
12
|
|
|
exit; |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
if ( ! class_exists( 'Black_Studio_TinyMCE_Widget\\Compatibility\\WordPress\\WordPress_Pre_35', false ) ) { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class that provides compatibility code for WordPress versions prior to 3.5 |
|
19
|
|
|
* |
|
20
|
|
|
* @package Black_Studio_TinyMCE_Widget |
|
21
|
|
|
* @since 3.0.0 |
|
22
|
|
|
*/ |
|
23
|
|
|
final class Pre_35 { |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The single instance of the class |
|
27
|
|
|
* |
|
28
|
|
|
* @var object |
|
29
|
|
|
* @since 3.0.0 |
|
30
|
|
|
*/ |
|
31
|
|
|
protected static $_instance = null; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Return the single class instance |
|
35
|
|
|
* |
|
36
|
|
|
* @return object |
|
37
|
|
|
* @since 3.0.0 |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function instance() { |
|
40
|
|
|
if ( is_null( self::$_instance ) ) { |
|
41
|
|
|
self::$_instance = new self(); |
|
42
|
|
|
} |
|
43
|
|
|
return self::$_instance; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Class constructor |
|
48
|
|
|
* |
|
49
|
|
|
* @uses add_action() |
|
50
|
|
|
* |
|
51
|
|
|
* @since 3.0.0 |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function __construct() { |
|
54
|
|
|
add_action( 'admin_init', array( $this, 'admin_init' ), 35 ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Prevent the class from being cloned |
|
59
|
|
|
* |
|
60
|
|
|
* @return void |
|
61
|
|
|
* @since 3.0.0 |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function __clone() { |
|
64
|
|
|
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ uh?' ), '3.0' ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Admin init |
|
69
|
|
|
* |
|
70
|
|
|
* @uses add_filter() |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
* @since 3.0.0 |
|
74
|
|
|
*/ |
|
75
|
|
|
public function admin_init() { |
|
76
|
|
|
if ( bstw()->admin()->enabled() ) { |
|
77
|
|
|
add_filter( '_upload_iframe_src', array( $this, 'upload_iframe_src' ), 65 ); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Enable full media options in upload dialog |
|
83
|
|
|
* (this is done excluding post_id parameter in Thickbox iframe url) |
|
84
|
|
|
* |
|
85
|
|
|
* @global string $pagenow |
|
86
|
|
|
* @param string $upload_iframe_src Source of the iframe for the upload dialog. |
|
87
|
|
|
* @return string |
|
88
|
|
|
* @since 3.0.0 |
|
89
|
|
|
*/ |
|
90
|
|
|
public function upload_iframe_src( $upload_iframe_src ) { |
|
91
|
|
|
global $pagenow; |
|
92
|
|
|
$id_base = filter_var( INPUT_POST, 'id_base' ); |
|
93
|
|
|
if ( 'widgets.php' === $pagenow || ( 'admin-ajax.php' === $pagenow && 'black-studio-tinymce' === $id_base ) ) { |
|
94
|
|
|
$upload_iframe_src = str_replace( 'post_id=0', '', $upload_iframe_src ); |
|
95
|
|
|
} |
|
96
|
|
|
return $upload_iframe_src; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
} // END class |
|
100
|
|
|
|
|
101
|
|
|
} // END class_exists |
|
102
|
|
|
|