Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #376 from Codeinwp/development
Browse files Browse the repository at this point in the history
Fix issues with Gutenberg
Tested upto 5.1
  • Loading branch information
contactashish13 authored Feb 28, 2019
2 parents 7e32a60 + 7c8e749 commit 2bb7135
Show file tree
Hide file tree
Showing 13 changed files with 875 additions and 694 deletions.
6 changes: 3 additions & 3 deletions includes/admin/class-wppr-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ public function set_editor() {
$current_screen = get_current_screen();

$back_compat_meta_box = array(
'__back_compat_meta_box' => false,
'__back_compat_meta_box' => true,
);

if ( ! class_exists( 'Classic_Editor' ) || $current_screen->is_block_editor() ) {
if ( ( class_exists( 'Classic_Editor' ) && ! $current_screen->is_block_editor() ) || ! $current_screen->is_block_editor() ) {
$back_compat_meta_box = array(
'__back_compat_meta_box' => true,
'__back_compat_meta_box' => false,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wppr.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class WPPR {
*/
public function __construct() {
$this->plugin_name = 'wppr';
$this->version = '3.5.1';
$this->version = '3.5.2';

$this->load_dependencies();
$this->set_locale();
Expand Down
2 changes: 2 additions & 0 deletions includes/gutenberg/build/sidebar.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

832 changes: 832 additions & 0 deletions includes/gutenberg/build/sidebar.js

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions includes/gutenberg/class-wppr-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function __construct() {
$this->version = $plugin->get_version();
// Add a filter to load functions when all plugins have been loaded
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_gutenberg_scripts' ) );
add_action( 'init', array( $this, 'register_endpoints' ) );
add_action( 'wp_loaded', array( $this, 'register_endpoints' ) );
add_action( 'rest_api_init', array( $this, 'update_posts_endpoints' ) );
add_filter( 'rest_post_query', array( $this, 'post_meta_request_params' ), 99, 2 );
add_filter( 'rest_page_query', array( $this, 'post_meta_request_params' ), 99, 2 );
Expand All @@ -55,7 +55,7 @@ private function __construct() {
*/
public function enqueue_gutenberg_scripts() {
if ( WPPR_CACHE_DISABLED ) {
$version = filemtime( WPPR_URL . '/includes/gutenberg/dist/sidebar.js' );
$version = filemtime( WPPR_PATH . '/includes/gutenberg/build/sidebar.js' );
} else {
$version = $this->version;
}
Expand All @@ -70,7 +70,7 @@ public function enqueue_gutenberg_scripts() {
$length = $model->wppr_get_option( 'cwppos_option_nr' );

// Enqueue the bundled block JS file
wp_enqueue_script( 'wppr-gutenberg-block-js', WPPR_URL . '/includes/gutenberg/dist/sidebar.js', array( 'wp-i18n', 'wp-edit-post', 'wp-element', 'wp-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-plugins', 'wp-edit-post', 'wp-api' ), $version );
wp_enqueue_script( 'wppr-gutenberg-block-js', WPPR_URL . '/includes/gutenberg/build/sidebar.js', array( 'wp-i18n', 'wp-edit-post', 'wp-element', 'wp-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-plugins', 'wp-edit-post', 'wp-api' ), $version );

wp_localize_script(
'wppr-gutenberg-block-js',
Expand All @@ -83,7 +83,7 @@ public function enqueue_gutenberg_scripts() {
);

// Enqueue editor block styles
wp_enqueue_style( 'wppr-gutenberg-block-css', WPPR_URL . '/includes/gutenberg/dist/sidebar.css', '', $version );
wp_enqueue_style( 'wppr-gutenberg-block-css', WPPR_URL . '/includes/gutenberg/build/sidebar.css', '', $version );
}

/**
Expand Down Expand Up @@ -153,8 +153,17 @@ public function update_review_callback( $data ) {
* Register Rest Field
*/
public function register_endpoints() {
$args = array(
'public' => true,
);

$output = 'names';
$operator = 'and';

$post_types = get_post_types( $args, $output, $operator );

register_rest_field(
array( 'post', 'wppr_review' ),
$post_types,
'wppr_data',
array(
'get_callback' => array( $this, 'get_post_meta' ),
Expand Down
Loading

0 comments on commit 2bb7135

Please sign in to comment.