[bugfix request] Support loading via AJAX
-
I was able to get this plugin working with AJAX by making sure to include the main JS/CSS on the page ahead of time (instantiate the Metaslider classes and call enqueue_scripts), then loading posts that contain MetaSlider shortcode.
The only issue is that when you are logged in, the slides will show up with the admin HTML, because the WordPress AJAX framework will cause is_admin() to be true. The simple solution is shown below for metaslide.class.php. I am detecting AJAX calls and specifically rendering the public HTML.
public function get_slide_html() { if ( is_admin() && ((isset( $_GET['page'] ) && $_GET['page'] == 'metaslider-theme-editor') || (defined( 'DOING_AJAX' ) && DOING_AJAX) ) ) { return $this->get_public_slide(); } $capability = apply_filters( 'metaslider_capability', 'edit_others_posts' ); if ( is_admin() && current_user_can( $capability ) && ! isset( $_GET['slider_id'] ) ) { return $this->get_admin_slide(); } return $this->get_public_slide(); }
Would it be possible to make this modification in the next update of the plugin so I don’t need to manually modify the plugin with every update? I believe this is a safe fix with no regression in current behavior without AJAX.
- The topic ‘[bugfix request] Support loading via AJAX’ is closed to new replies.