PluginProbe
Inactive Logout / trunk
Inactive Logout vtrunk
3.6.3 trunk 1.9.9 2.0.2 3.3.1 3.3.2 3.3.3 3.3.4 3.4.0 3.4.1 3.4.10 3.4.11 3.4.12 3.4.13 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 All 31 releases
inactive-logout / core / Backend / Common.php

Common.php in Inactive Logout trunk, at core/Backend/Common.php

77 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Codemanas\InactiveLogout\Backend;
4
5 use Codemanas\InactiveLogout\Helpers;
6 use Codemanas\InactiveLogout\Modal;
7
8 class Common {
9
10 public function dismissNotices() {
11 Helpers::update_option( 'ina_dismiss_like_notice', true );
12 }
13
14 private function getPostTypeQuery() {
15 $q = filter_input( INPUT_GET, 'q' );
16
17 $args = [
18 's' => $q,
19 'post_type' => apply_filters( 'ina_free_get_custom_post_types', array( 'post', 'page' ) ),
20 'post_status' => 'publish',
21 ];
22
23 // The Query
24 return new \WP_Query( $args );
25 }
26
27 public function triggerDemoToast() {
28 $message = Helpers::getSettings( 'after_redirection_toast_message' );
29 $message = ! empty( $message ) ? $message : 'You have been automatically logged out due to inactivity';
30 $modal = Modal::instance();
31 $content = $modal->getToastStyle();
32 $content .= $modal->getToastHTML( $message );
33 wp_send_json( $content );
34
35 wp_die();
36 }
37
38 public function filterPostPagesUrl() {
39 // The Query
40 $posts_query = $this->getPostTypeQuery();
41
42 $posts = [];
43 if ( ! empty( $posts_query->have_posts() ) ) {
44 foreach ( $posts_query->get_posts() as $post ) {
45 $posts[] = [ 'text' => get_permalink( $post->ID ), 'id' => get_permalink( $post->ID ) ];
46 }
47 }
48 wp_reset_postdata();
49 wp_send_json( $posts );
50 wp_die();
51 }
52
53 public function filterPostPagesId() {
54 $posts_query = $this->getPostTypeQuery();
55
56 $posts = [];
57 if ( ! empty( $posts_query->have_posts() ) ) {
58 foreach ( $posts_query->get_posts() as $post ) {
59 $posts[] = [ 'text' => $post->post_title, 'id' => $post->ID ];
60 }
61 }
62 wp_reset_postdata();
63 wp_send_json( $posts );
64 wp_die();
65 }
66
67 private static ?Common $_instance = null;
68
69 public static function getInstance(): ?Common {
70 if ( is_null( self::$_instance ) ) {
71 self::$_instance = new self();
72 }
73
74 return self::$_instance;
75 }
76 }
77