Merge lp:~caleb-ellis/resource-centre/remove-youtube-metabox into lp:resource-centre

Proposed by Caleb Ellis
Status: Merged
Approved by: Anthony Dillon
Approved revision: 107
Merged at revision: 106
Proposed branch: lp:~caleb-ellis/resource-centre/remove-youtube-metabox
Merge into: lp:resource-centre
Diff against target: 159 lines (+21/-46)
1 file modified
functions/metaboxes.php (+21/-46)
To merge this branch: bzr merge lp:~caleb-ellis/resource-centre/remove-youtube-metabox
Reviewer Review Type Date Requested Status
Anthony Dillon Approve
Review via email: mp+337775@code.launchpad.net

Description of the change

Removed YouTube metabox from insights admin page

To post a comment you must log in.
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Looks good thanks.

I have installed the change on insights.canonicalwebteam.com and the video metabox is not there in the admin.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'functions/metaboxes.php'
--- functions/metaboxes.php 2017-10-16 15:09:37 +0000
+++ functions/metaboxes.php 2018-02-15 12:29:47 +0000
@@ -3,19 +3,19 @@
3define('WYSIWYG_META_BOX_ID', 'dbt_press_links');3define('WYSIWYG_META_BOX_ID', 'dbt_press_links');
4define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different4define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
5define('WYSIWYG_META_KEY', 'dbt_press_links');5define('WYSIWYG_META_KEY', 'dbt_press_links');
6 6
7add_action('admin_init', 'wysiwyg_register_meta_box');7add_action('admin_init', 'wysiwyg_register_meta_box');
8function wysiwyg_register_meta_box(){8function wysiwyg_register_meta_box(){
9 add_meta_box(WYSIWYG_META_BOX_ID, __('Press release links', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');9 add_meta_box(WYSIWYG_META_BOX_ID, __('Press release links', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
10}10}
11 11
12function wysiwyg_render_meta_box(){12function wysiwyg_render_meta_box(){
13 13
14 global $post;14 global $post;
15 15
16 $meta_box_id = WYSIWYG_META_BOX_ID;16 $meta_box_id = WYSIWYG_META_BOX_ID;
17 $editor_id = WYSIWYG_EDITOR_ID;17 $editor_id = WYSIWYG_EDITOR_ID;
18 18
19 echo "<p>Add press release links here using the 'insert link' tool on the toolbar (new line for each link)</p>";19 echo "<p>Add press release links here using the 'insert link' tool on the toolbar (new line for each link)</p>";
20 //Add CSS & jQuery goodness to make this work like the original WYSIWYG20 //Add CSS & jQuery goodness to make this work like the original WYSIWYG
21 echo "21 echo "
@@ -25,26 +25,26 @@
25 #$meta_box_id #editorcontainer{background:#fff !important;}25 #$meta_box_id #editorcontainer{background:#fff !important;}
26 #$meta_box_id #$editor_id_fullscreen{display:none;}26 #$meta_box_id #$editor_id_fullscreen{display:none;}
27 </style>27 </style>
28 28
29 <script type='text/javascript'>29 <script type='text/javascript'>
30 jQuery(function($){30 jQuery(function($){
31 $('#$meta_box_id #editor-toolbar > a').click(function(){31 $('#$meta_box_id #editor-toolbar > a').click(function(){
32 $('#$meta_box_id #editor-toolbar > a').removeClass('active');32 $('#$meta_box_id #editor-toolbar > a').removeClass('active');
33 $(this).addClass('active');33 $(this).addClass('active');
34 });34 });
35 35
36 if($('#$meta_box_id #edButtonPreview').hasClass('active')){36 if($('#$meta_box_id #edButtonPreview').hasClass('active')){
37 $('#$meta_box_id #ed_toolbar').hide();37 $('#$meta_box_id #ed_toolbar').hide();
38 }38 }
39 39
40 $('#$meta_box_id #edButtonPreview').click(function(){40 $('#$meta_box_id #edButtonPreview').click(function(){
41 $('#$meta_box_id #ed_toolbar').hide();41 $('#$meta_box_id #ed_toolbar').hide();
42 });42 });
43 43
44 $('#$meta_box_id #edButtonHTML').click(function(){44 $('#$meta_box_id #edButtonHTML').click(function(){
45 $('#$meta_box_id #ed_toolbar').show();45 $('#$meta_box_id #ed_toolbar').show();
46 });46 });
47 47
48 //Tell the uploader to insert content into the correct WYSIWYG editor48 //Tell the uploader to insert content into the correct WYSIWYG editor
49 $('#media-buttons a').bind('click', function(){49 $('#media-buttons a').bind('click', function(){
50 var customEditor = $(this).parents('#$meta_box_id');50 var customEditor = $(this).parents('#$meta_box_id');
@@ -58,24 +58,24 @@
58 });58 });
59 </script>59 </script>
60 ";60 ";
61 61
62 //Create The Editor62 //Create The Editor
63 $content = get_post_meta($post->ID, WYSIWYG_META_KEY, true);63 $content = get_post_meta($post->ID, WYSIWYG_META_KEY, true);
64 wp_editor($content, $editor_id);64 wp_editor($content, $editor_id);
65 65
66 //Clear The Room!66 //Clear The Room!
67 echo "<div style='clear:both; display:block;'></div>";67 echo "<div style='clear:both; display:block;'></div>";
68}68}
69 69
70add_action('save_post', 'wysiwyg_save_meta');70add_action('save_post', 'wysiwyg_save_meta');
71function wysiwyg_save_meta(){71function wysiwyg_save_meta(){
72 72
73 $editor_id = WYSIWYG_EDITOR_ID;73 $editor_id = WYSIWYG_EDITOR_ID;
74 $meta_key = WYSIWYG_META_KEY;74 $meta_key = WYSIWYG_META_KEY;
75 75
76 if(isset($_REQUEST[$editor_id]))76 if(isset($_REQUEST[$editor_id]))
77 update_post_meta($_REQUEST['post_ID'], WYSIWYG_META_KEY, $_REQUEST[$editor_id]);77 update_post_meta($_REQUEST['post_ID'], WYSIWYG_META_KEY, $_REQUEST[$editor_id]);
78 78
79}79}
8080
81add_filter( 'dbt_press_contact', 'make_clickable', 9 );81add_filter( 'dbt_press_contact', 'make_clickable', 9 );
@@ -122,8 +122,8 @@
122 //'type' => 'text'122 //'type' => 'text'
123 //)123 //)
124 )124 )
125); 125);
126 126
127add_action('admin_menu', 'mytheme_add_box');127add_action('admin_menu', 'mytheme_add_box');
128128
129// Add meta box129// Add meta box
@@ -152,7 +152,7 @@
152 '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',152 '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
153 '<td>';153 '<td>';
154 switch ($field['type']) {154 switch ($field['type']) {
155 155
156 case 'checkbox':156 case 'checkbox':
157 echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';157 echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
158 break;158 break;
@@ -207,31 +207,6 @@
207 }207 }
208}208}
209209
210// add youtube metabox
211add_action('admin_menu', 'insights_meta_boxes');
212function insights_meta_boxes() {
213 if ( function_exists('add_meta_box') ) {
214 add_meta_box('post_id', 'YouTube', 'custom_post_video', 'post', 'normal', 'high');
215 //add_meta_box('post_id', 'YouTube', 'custom_post_video', 'video', 'normal', 'high');
216 }
217}
218
219//Adds the youtube box in admin
220function custom_post_video() {
221 global $post;
222 ?>
223 <div class="inside">
224 <p>
225 <label for="postVideo">Code</label>
226 <input type="text" name="postVideo" id="postVideo" value="<?php echo get_post_meta($post->ID, 'postVideo', true); ?>">
227 </p>
228 <p>Enter the YouTube video 11 digit code here e.g from this url http://www.youtube.com/watch?v=D6z6hn6wZlg you need the 11 digits after ?v= i.e <strong>D6z6hn6wZlg</strong></p>
229
230 <p>Enter the codes comma separated (no space) if you have more than one e.g: <strong>h384z7Ph0gU,5_4fXQcxFRs</strong></p>
231 </div>
232<?php
233}
234
235add_action('save_post', 'custom_add_save');210add_action('save_post', 'custom_add_save');
236211
237function custom_add_save($postID){212function custom_add_save($postID){
@@ -245,7 +220,7 @@
245 {220 {
246 $postID = $parent_id;221 $postID = $parent_id;
247 }222 }
248 if ($_POST['postVideo']) 223 if ($_POST['postVideo'])
249 {224 {
250 update_custom_meta($postID, $_POST['postVideo'], 'postVideo');225 update_custom_meta($postID, $_POST['postVideo'], 'postVideo');
251 }226 }
@@ -266,4 +241,4 @@
266 }241 }
267}242}
268243
269?>
270\ No newline at end of file244\ No newline at end of file
245?>

Subscribers

People subscribed via source and target branches