Plugin Directory

Changeset 2092539


Ignore:
Timestamp:
05/21/2019 06:25:15 PM (7 years ago)
Author:
webcraftic
Message:

Update plugin Woody ad snippets up to 2.2.3

Location:
insert-php/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • insert-php/trunk/admin/metaboxes/base-options.php

    r2090793 r2092539  
    5959        add_action( 'post_submitbox_misc_actions', [ $this, 'post_submitbox_misc_actions' ] );
    6060        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 );
    6164    }
    6265
     
    9699            ] );
    97100        }
     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;
    98168    }
    99169
  • insert-php/trunk/insert_php.php

    r2091192 r2092539  
    55 * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service’s code. Ensures no content duplication.
    66 * Author: Will Bontrager Software, LLC <will@willmaster.com>, Webcraftic <wordpress.webraftic@gmail.com>
    7  * Version: 2.2.2
     7 * Version: 2.2.3
    88 * Text Domain: insert-php
    99 * Domain Path: /languages/
  • insert-php/trunk/migrations/020200.php

    r2090793 r2092539  
    3030
    3131        $this->new_migration();
    32         WINP_Helper::flush_page_cache();
    3332    }
    3433
     
    109108
    110109                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, [
    114111                        'post_content' => $snippet_code
    115                     ] );
     112                    ], [
     113                        'ID'        => (int) $snippet->ID,
     114                        'post_type' => WINP_SNIPPETS_POST_TYPE
     115                    ], [ '%s' ], [ '%d', '%s' ] );
    116116
    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 );
    120118                }
    121119
Note: See TracChangeset for help on using the changeset viewer.