PluginProbe
FeedWordPress / 2022.0208
FeedWordPress v2022.0208
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / feedwordpress.wp-admin.post-edit.functions.php

feedwordpress.wp-admin.post-edit.functions.php in FeedWordPress 2022.0208, at feedwordpress.wp-admin.post-edit.functions.php

105 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function feedwordpress_add_post_edit_controls () {
3 global $feedwordpress;
4 global $inspectPostMeta;
5
6 // Put in Manual Editing checkbox
7 add_action('add_meta_boxes', 'feedwordpress_post_add_meta_boxes', 10, 2);
8
9 add_filter('user_can_richedit', array($feedwordpress, 'user_can_richedit'), 1000, 1);
10
11 if (FeedWordPressDiagnostic::is_on('syndicated_posts:static_meta_data')) :
12 $inspectPostMeta = new InspectPostMeta;
13 endif;
14 } // function feedwordpress_add_post_edit_controls ()
15
16 function feedwordpress_post_add_meta_boxes ($post_type, $post) {
17 add_meta_box(
18 'feedwordpress-post-controls',
19 __('Syndication'),
20 'feedwordpress_post_edit_controls',
21 $post_type,
22 'side',
23 'high'
24 );
25 }
26
27 function feedwordpress_post_edit_controls () {
28 global $post;
29
30 $frozen_values = get_post_custom_values('_syndication_freeze_updates', $post->ID);
31 $frozen_post = ($frozen_values !== null and count($frozen_values) > 0 and 'yes' == $frozen_values[0]);
32
33 if (is_syndicated($post->ID)) :
34 ?>
35 <p>This is a syndicated post, which originally appeared at
36 <cite><?php print esc_html(get_syndication_source(NULL, $post->ID)); ?></cite>.
37 <a href="<?php print esc_html(get_syndication_permalink($post->ID)); ?>">View original post</a>.</p>
38
39 <?php do_action('feedwordpress_post_edit_controls_pre', $post); ?>
40
41 <p><input type="hidden" name="feedwordpress_noncename" id="feedwordpress_noncename" value="<?php print wp_create_nonce(plugin_basename(__FILE__)); ?>" />
42 <label><input type="checkbox" name="freeze_updates" value="yes" <?php if ($frozen_post) : ?>checked="checked"<?php endif; ?> /> <strong>Manual editing.</strong>
43 If set, FeedWordPress will not overwrite the changes you make manually
44 to this post, if the syndicated content is updated on the
45 feed.</label></p>
46
47 <?php do_action('feedwordpress_post_edit_controls', $post); ?>
48
49 <?php
50 else :
51 ?>
52 <p>This post was created locally at this website.</p>
53 <?php
54 endif;
55 } /* function feedwordpress_post_edit_controls () */
56
57 function feedwordpress_save_post_edit_controls ( $post_id ) {
58 global $post;
59 if (!isset($_POST['feedwordpress_noncename']) or !wp_verify_nonce($_POST['feedwordpress_noncename'], plugin_basename(__FILE__))) :
60 return $post_id;
61 endif;
62
63 // Verify if this is an auto save routine. If it is our form has
64 // not been submitted, so we don't want to do anything.
65 if ( defined('DOING_AUTOSAVE') and DOING_AUTOSAVE ) :
66 return $post_id;
67 endif;
68
69 // The data in $_POST is for applying only to the post actually
70 // in the edit window, i.e. $post
71 if ($post_id != $post->ID) :
72 return $post_id;
73 endif;
74
75 // Check permissions
76 $cap[0] = 'edit_post';
77 $cap[1] = 'edit_' . $_POST['post_type'];
78 if (
79 !current_user_can( $cap[0], $post_id )
80 and !current_user_can( $cap[1], $post_id )
81 ) :
82 return $post_id;
83 endif;
84
85 // OK, we're golden. Now let's save some data.
86 if (isset($_POST['freeze_updates'])) :
87 $sFreezeUpdates = sanitize_text_field($_POST['freeze_updates']);
88 update_post_meta($post_id, '_syndication_freeze_updates', sanitize_meta('_syndication_freeze_updates', $sFreezeUpdates, 'post'));
89 $ret = $sFreezeUpdates;
90
91 // If you make manual edits through the WordPress editing
92 // UI then they should be run through normal WP formatting
93 // filters.
94 update_post_meta($post_id, '_feedwordpress_formatting_filters', 'yes');
95
96 else :
97 delete_post_meta($post_id, '_syndication_freeze_updates');
98 $ret = NULL;
99 endif;
100
101 do_action('feedwordpress_save_edit_controls', $post_id);
102
103 return $ret;
104 } // function feedwordpress_save_edit_controls
105