Changeset 2092539
- Timestamp:
- 05/21/2019 06:25:15 PM (7 years ago)
- Location:
- insert-php/trunk
- Files:
-
- 1 added
- 3 edited
-
admin/metaboxes/base-options.php (modified) (2 diffs)
-
insert_php.php (modified) (1 diff)
-
migrations/020200.php (modified) (2 diffs)
-
migrations/020203.php (added)
Legend:
- Unmodified
- Added
- Removed
-
insert-php/trunk/admin/metaboxes/base-options.php
r2090793 r2092539 59 59 add_action( 'post_submitbox_misc_actions', [ $this, 'post_submitbox_misc_actions' ] ); 60 60 add_action( 'edit_form_after_title', [ $this, 'keep_html_entities' ] ); 61 62 add_filter( 'pre_post_content', [ $this, 'stop_post_filters' ] ); 63 add_filter( 'content_save_pre', [ $this, 'init_post_filters' ], 9999 ); 61 64 } 62 65 … … 96 99 ] ); 97 100 } 101 } 102 103 /** 104 * Disable post filtering. Snippets code cannot be filtered, otherwise it will cause errors. 105 * 106 * @author Alexander Kovalev <alex.kovalevv@gmail.com> 107 * @since 2.2.3 108 * 109 * @param $value 110 * 111 * @return mixed 112 */ 113 public function stop_post_filters( $value ) { 114 global $wbcr__has_kses, $wbcr__has_targeted_link_rel_filters; 115 116 $screen = get_current_screen(); 117 if ( empty( $screen ) || $screen->post_type !== WINP_SNIPPETS_POST_TYPE ) { 118 return $value; 119 } 120 121 $snippet_type = WINP_Helper::get_snippet_type(); 122 123 if ( $snippet_type !== WINP_SNIPPET_TYPE_TEXT ) { 124 // Prevent content filters from corrupting JSON in post_content. 125 $wbcr__has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); 126 if ( $wbcr__has_kses ) { 127 kses_remove_filters(); 128 } 129 $wbcr__has_targeted_link_rel_filters = ( false !== has_filter( 'content_save_pre', 'wp_targeted_link_rel' ) ); 130 if ( $wbcr__has_targeted_link_rel_filters ) { 131 wp_remove_targeted_link_rel_filters(); 132 } 133 } 134 135 return $value; 136 } 137 138 /** 139 * Enable post filtering. 140 * 141 * @author Alexander Kovalev <alex.kovalevv@gmail.com> 142 * @since 2.2.3 143 * 144 * @param $value 145 * 146 * @return mixed 147 */ 148 public function init_post_filters( $value ) { 149 global $wbcr__has_kses, $wbcr__has_targeted_link_rel_filters; 150 151 $screen = get_current_screen(); 152 if ( empty( $screen ) || $screen->post_type !== WINP_SNIPPETS_POST_TYPE ) { 153 return $value; 154 } 155 156 if ( $wbcr__has_kses ) { 157 kses_init_filters(); 158 } 159 160 if ( $wbcr__has_targeted_link_rel_filters ) { 161 wp_init_targeted_link_rel_filters(); 162 } 163 164 unset( $wbcr__has_kses ); 165 unset( $wbcr__has_targeted_link_rel_filters ); 166 167 return $value; 98 168 } 99 169 -
insert-php/trunk/insert_php.php
r2091192 r2092539 5 5 * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service’s code. Ensures no content duplication. 6 6 * Author: Will Bontrager Software, LLC <will@willmaster.com>, Webcraftic <wordpress.webraftic@gmail.com> 7 * Version: 2.2. 27 * Version: 2.2.3 8 8 * Text Domain: insert-php 9 9 * Domain Path: /languages/ -
insert-php/trunk/migrations/020200.php
r2090793 r2092539 30 30 31 31 $this->new_migration(); 32 WINP_Helper::flush_page_cache();33 32 } 34 33 … … 109 108 110 109 if ( ! empty( $snippet_code ) ) { 111 $result = wp_update_post( [ 112 'ID' => (int) $snippet->ID, 113 'post_type' => WINP_SNIPPETS_POST_TYPE, 110 $wpdb->update( $wpdb->posts, [ 114 111 'post_content' => $snippet_code 115 ] ); 112 ], [ 113 'ID' => (int) $snippet->ID, 114 'post_type' => WINP_SNIPPETS_POST_TYPE 115 ], [ '%s' ], [ '%d', '%s' ] ); 116 116 117 //if ( ! is_wp_error( $result ) && $result ) { 118 //WINP_Helper::removeMetaOption( $snippet->ID, 'snippet_code' ); 119 //} 117 WINP_Helper::updateMetaOption( $snippet->ID, 'snippet_code_moved', 1 ); 120 118 } 121 119
Note: See TracChangeset
for help on using the changeset viewer.