PluginProbe
Assistant – Every Day Productivity Apps / 1.5.5.1
Assistant – Every Day Productivity Apps v1.5.5.1
1.5.5.1 1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 All 72 releases
← All changes | backend/src/Hooks/PostPreview.php +38 -16 0.6.0 → 1.5.5.1 View file →
@@ -7,27 +7,27 @@
7 7 protected $post_id;
8 8
9 9 public function __construct() {
10 10 if ( isset( $_GET['fl_asst_post_preview'] ) ) {
11 - self::init();
12 - }
13 - }
11 + if ( isset( $_GET['p'] ) ) {
12 + $this->post_id = absint( $_GET['p'] );
13 + } elseif ( isset( $_GET['page_id'] ) ) {
14 + $this->post_id = absint( $_GET['page_id'] );
15 + }
14 16
15 - public function init() {
16 - if ( isset( $_GET['p'] ) ) {
17 - $this->post_id = absint( $_GET['p'] );
18 - } elseif ( isset( $_GET['page_id'] ) ) {
19 - $this->post_id = absint( $_GET['page_id'] );
20 - } else {
21 - return;
17 + if ( $this->post_id ) {
18 + add_action( 'parse_query', [ $this, 'parse_query' ], PHP_INT_MAX );
19 + add_filter( 'redirect_canonical', '__return_false', PHP_INT_MAX );
20 + }
22 21 }
23 22
24 - add_action( 'parse_query', [ $this, 'parse_query' ], PHP_INT_MAX );
25 - add_filter( 'redirect_canonical', '__return_false', PHP_INT_MAX );
26 -
27 23 if ( isset( $_GET['fl_asst_screenshot'] ) ) {
28 - add_action( 'wp', [ $this, 'disable_known_theme_parts' ], PHP_INT_MAX );
29 24 add_filter( 'body_class', [ $this, 'body_class' ] );
25 + show_admin_bar( false );
26 +
27 + if ( $this->post_id ) {
28 + add_action( 'wp', [ $this, 'disable_known_theme_parts' ], PHP_INT_MAX );
29 + }
30 30 }
31 31 }
32 32
33 33 public function parse_query( $query ) {
@@ -33,9 +33,8 @@
33 33 public function parse_query( $query ) {
34 34 if ( $query->is_main_query() ) {
35 35 if ( current_user_can( 'edit_others_posts' ) ) {
36 36 add_filter( 'posts_results', [ $this, 'override_posts_results' ], PHP_INT_MAX );
37 - show_admin_bar( false );
38 37 }
39 38 }
40 39 }
41 40
@@ -49,14 +48,15 @@
49 48 }
50 49
51 50 public function disable_known_theme_parts() {
52 51 $this->disable_bb_theme();
52 + $this->disable_bb_themer();
53 53 $this->disable_generate_press();
54 54 $this->disable_genesis();
55 55 }
56 56
57 57 public function body_class( $classes ) {
58 - $classes[] = 'fl-asst-sceenshot';
58 + $classes[] = 'fl-asst-screenshot';
59 59 return $classes;
60 60 }
61 61
62 62 protected function disable_bb_theme() {
@@ -63,8 +63,30 @@
63 63 add_filter( 'fl_topbar_enabled', '__return_false' );
64 64 add_filter( 'fl_fixed_header_enabled', '__return_false' );
65 65 add_filter( 'fl_header_enabled', '__return_false' );
66 66 add_filter( 'fl_footer_enabled', '__return_false' );
67 + }
68 +
69 + protected function disable_bb_themer() {
70 + if ( ! defined( 'FL_THEME_BUILDER_VERSION' ) ) {
71 + return;
72 + }
73 +
74 + $is_header = \FLThemeBuilderLayoutData::current_post_is( 'header' );
75 + $is_footer = \FLThemeBuilderLayoutData::current_post_is( 'footer' );
76 + $is_part = \FLThemeBuilderLayoutData::current_post_is( 'part' );
77 +
78 + if ( ! $is_header ) {
79 + remove_all_actions( 'fl_before_header' );
80 + }
81 + if ( ! $is_footer ) {
82 + remove_all_actions( 'fl_after_content' );
83 + }
84 + if ( $is_header || $is_footer || $is_part ) {
85 + add_action( 'wp_print_scripts', function() {
86 + echo '<style>.fl-asst-screenshot .fl-theme-builder-content-placeholder { display: none; }</style>';
87 + } );
88 + }
67 89 }
68 90
69 91 protected function disable_generate_press() {
70 92 remove_action( 'generate_header', 'generate_construct_header' );