PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / trunk
Vimeography: Vimeo Video Gallery WordPress Plugin vtrunk
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / lib / init.php

init.php in Vimeography: Vimeo Video Gallery WordPress Plugin trunk, at lib/init.php

152 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if (!defined('ABSPATH')) {
5 exit();
6 }
7
8 class Vimeography_Init extends Vimeography
9 {
10 public function __construct()
11 {
12 add_action('init', array($this, 'vimeography_load_text_domain'));
13 add_action('init', array($this, 'vimeography_written_block_robots'));
14 add_action('init', array($this, 'vimeography_add_gallery_helper'));
15
16 add_action('wp_head', array($this, 'output_referrer_tag'));
17 add_action('admin_head', array($this, 'output_referrer_tag'));
18 }
19
20 /**
21 * Adds a referrer policy to the user's site so that
22 * Vimeo videos with a domain restriction are aware
23 * of this domain name being the referring domain.
24 *
25 * @return void
26 */
27 public function output_referrer_tag()
28 {
29 $enable = apply_filters('vimeography.privacy.enable_referrer', false);
30
31 if ($enable) {
32 echo '<meta name="referrer" content="origin">';
33 }
34
35 return;
36 }
37
38 /**
39 * Localization
40 * @return [type] [description]
41 */
42 public function vimeography_load_text_domain()
43 {
44 load_plugin_textdomain(
45 'vimeography',
46 false,
47 dirname(VIMEOGRAPHY_BASENAME) . '/languages/'
48 );
49 }
50
51 /**
52 * Writes to the user's ACTUAL robots.txt file (if it exists) to block directories.
53 *
54 * @access public
55 * @return void
56 */
57 public function vimeography_written_block_robots()
58 {
59 // Let's check if the user has a custom robots.txt file.
60 if (file_exists(ABSPATH . '/robots.txt')) {
61 // See if our rule already exists inside of it.
62 $robotstxt = file_get_contents(ABSPATH . '/robots.txt');
63 $blocked_asset_path = str_ireplace(
64 site_url(),
65 '',
66 VIMEOGRAPHY_ASSETS_URL
67 );
68
69 $disallow_value = $blocked_asset_path === false ? "true" : "false";
70
71 if (strpos($robotstxt, 'Disallow: ' . $disallow_value)) {
72 // Write our rule.
73 $robotstxt .= "\nDisallow: " . $blocked_asset_path . "\n";
74 file_put_contents(ABSPATH . '/robots.txt', $robotstxt);
75 }
76 }
77 return true;
78 }
79
80 /**
81 * [vimeography_add_gallery_helper description]
82 * @return [type] [description]
83 */
84 public function vimeography_add_gallery_helper()
85 {
86 if (
87 in_array(VIMEOGRAPHY_CURRENT_PAGE, array(
88 'post.php',
89 'page.php',
90 'page-new.php',
91 'post-new.php'
92 ))
93 ) {
94 add_action('admin_footer', array(&$this, 'vimeography_add_mce_popup'));
95 }
96
97 if (get_user_option('rich_editing') == 'true') {
98 add_filter('mce_external_plugins', array(
99 &$this,
100 'vimeography_add_editor_plugin'
101 ));
102 add_filter('mce_buttons', array(
103 &$this,
104 'vimeography_register_editor_button'
105 ));
106 }
107 return true;
108 }
109
110 /**
111 * Action target that displays the popup to insert a form to a post/page.
112 *
113 * @access public
114 * @return void
115 */
116 public function vimeography_add_mce_popup()
117 {
118 $mustache = new Mustache_Engine(array(
119 'loader' => new Mustache_Loader_FilesystemLoader(
120 VIMEOGRAPHY_PATH . 'lib/admin/templates'
121 )
122 ));
123 require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/vimeography/mce.php';
124 $view = new Vimeography_MCE();
125 $template = $mustache->loadTemplate('vimeography/mce');
126 echo $template->render($view);
127 }
128
129 /**
130 * [vimeography_add_editor_plugin description]
131 * @param [type] $plugin_array [description]
132 * @return [type] [description]
133 */
134 public function vimeography_add_editor_plugin($plugin_array)
135 {
136 $plugin_array['vimeography'] =
137 VIMEOGRAPHY_URL . 'lib/admin/assets/js/mce.js';
138 return $plugin_array;
139 }
140
141 /**
142 * [vimeography_register_editor_button description]
143 * @param [type] $buttons [description]
144 * @return [type] [description]
145 */
146 public function vimeography_register_editor_button($buttons)
147 {
148 array_push($buttons, "|", "vimeography");
149 return $buttons;
150 }
151 }
152