PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 4.1.2
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v4.1.2
7.9.3 7.9.2 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.2.0 4.2.1 4.2.2 4.2.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 6.0.0 7.0.0 7.0.1 7.0.2 7.1.0 7.2.0 7.2.1 7.2.10 7.2.11 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 7.2.8 7.2.9 7.3.0 7.3.1 7.4.0 7.4.1 7.4.2 7.4.3 7.5.0 7.6.0 7.6.1 7.7.0 7.7.1 7.7.10 7.7.11 7.7.12 7.7.13 7.7.14 7.7.15 7.7.16 7.7.17 7.7.18 7.7.19 7.7.2 7.7.20 7.7.21 7.7.22 7.7.3 7.7.4 7.7.5 7.7.6 7.7.7 7.7.8 7.7.9 7.8.0 7.8.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1
the-post-grid / app / Controllers / Admin / SettingsController.php
the-post-grid / app / Controllers / Admin Last commit date
AdminAjaxController.php 4 years ago MetaController.php 4 years ago NoticeController.php 4 years ago PostTypeController.php 4 years ago SettingsController.php 4 years ago UpgradeController.php 4 years ago
SettingsController.php
173 lines
1 <?php
2
3
4 namespace RT\ThePostGrid\Controllers\Admin;
5
6
7 use RT\ThePostGrid\Helpers\Fns;
8
9 class SettingsController {
10
11 private $sc_tag = 'rt_tpg_scg';
12
13 public function init() {
14 add_action( 'admin_menu', [ &$this, 'register' ] );
15 add_filter( 'plugin_action_links_' . RT_THE_POST_GRID_PLUGIN_ACTIVE_FILE_NAME, [ &$this, 'marketing' ] );
16 add_action( 'admin_enqueue_scripts', [ &$this, 'settings_admin_enqueue_scripts' ] );
17 add_action( 'wp_print_styles', [ &$this, 'tpg_dequeue_unnecessary_styles' ], 99 );
18 add_action( 'admin_footer', [ $this, 'pro_alert_html' ] );
19 add_action( 'admin_head', [ $this, 'admin_head' ] );
20 }
21
22 /**
23 * admin_head
24 * calls your functions into the correct filters
25 *
26 * @return void
27 */
28 function admin_head() {
29 // check user permissions
30 if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
31 return;
32 }
33 // check if WYSIWYG is enabled
34 if ( 'true' == get_user_option( 'rich_editing' ) ) {
35 add_filter( 'mce_external_plugins', [ $this, 'mce_external_plugins' ] );
36 add_filter( 'mce_buttons', [ $this, 'mce_buttons' ] );
37 echo "<style>";
38 echo "i.mce-i-rt_tpg_scg{";
39 echo "background: url('" . rtTPG()->get_assets_uri( 'images/icon-20x20.png' ) . "');";
40 echo "}";
41 echo "</style>";
42 }
43 }
44
45 /**
46 * mce_external_plugins
47 * Adds our tinymce plugin
48 *
49 * @param array $plugin_array
50 *
51 * @return array
52 */
53 function mce_external_plugins( $plugin_array ) {
54 $plugin_array[ $this->sc_tag ] = rtTPG()->get_assets_uri( 'js/mce-button.js' );
55
56 return $plugin_array;
57 }
58
59 /**
60 * mce_buttons
61 * Adds our tinymce button
62 *
63 * @param array $buttons
64 *
65 * @return array
66 */
67 function mce_buttons( $buttons ) {
68 array_push( $buttons, $this->sc_tag );
69
70 return $buttons;
71 }
72
73 public function pro_alert_html() {
74 global $typenow;
75
76 if ( rtTPG()->hasPro() ) {
77 return;
78 }
79
80 if ( ( isset( $_GET['page'] ) && $_GET['page'] != 'rttpg_settings' ) || $typenow != rtTPG()->post_type ) {
81 return;
82 }
83
84 $html = '';
85 $html .= '<div class="rt-document-box rt-alert rt-pro-alert">
86 <div class="rt-box-icon"><i class="dashicons dashicons-lock"></i></div>
87 <div class="rt-box-content">
88 <h3 class="rt-box-title">' . esc_html__( 'Pro field alert!', 'the-post-grid' ) . '</h3>
89 <p><span></span>' . esc_html__( 'Sorry! this is a pro field. To use this field, you need to use pro plugin.', 'the-post-grid' ) . '</p>
90 <a href="https://www.radiustheme.com/downloads/the-post-grid-pro-for-wordpress/" target="_blank" class="rt-admin-btn">' . esc_html__( "Upgrade to pro",
91 "the-post-grid" ) . '</a>
92 <a href="#" target="_blank" class="rt-alert-close rt-pro-alert-close">x</a>
93 </div>
94 </div>';
95 echo $html;
96 }
97
98 public function tpg_dequeue_unnecessary_styles() {
99 $settings = get_option( rtTPG()->options['settings'] );
100
101 if ( isset( $settings['tpg_skip_fa'] ) ) {
102 wp_dequeue_style( 'rt-fontawsome' );
103 wp_deregister_style( 'rt-fontawsome' );
104 }
105 }
106
107 public function settings_admin_enqueue_scripts() {
108 global $pagenow, $typenow;
109
110 // validate page
111 if ( ! in_array( $pagenow, [ 'edit.php' ] ) ) {
112 return;
113 }
114 if ( $typenow != rtTPG()->post_type ) {
115 return;
116 }
117
118 wp_enqueue_script( 'jquery' );
119 wp_enqueue_script( 'rt-tpg-admin' );
120
121 // styles
122 wp_enqueue_style( 'rt-tpg-admin' );
123
124 $nonce = wp_create_nonce( rtTPG()->nonceText() );
125 wp_localize_script( 'rt-tpg-admin',
126 'rttpg',
127 [
128 'nonceID' => rtTPG()->nonceId(),
129 'nonce' => $nonce,
130 'ajaxurl' => admin_url( 'admin-ajax.php' ),
131 ] );
132 }
133
134 function marketing( $links ) {
135 $links[] = '<a target="_blank" href="' . esc_url( 'https://www.radiustheme.com/demo/plugins/the-post-grid/' ) . '">Demo</a>';
136 $links[] = '<a target="_blank" href="' . esc_url( 'https://www.radiustheme.com/docs/the-post-grid/' ) . '">Documentation</a>';
137 if ( ! rtTPG()->hasPro() ) {
138 $links[] = '<a target="_blank" style="color: #39b54a;font-weight: 700;" href="' . esc_url( 'https://www.radiustheme.com/downloads/the-post-grid-pro-for-wordpress/' )
139 . '">Get Pro</a>';
140 }
141
142 return $links;
143 }
144
145 public function register() {
146 add_submenu_page(
147 'edit.php?post_type=' . rtTPG()->post_type,
148 __( 'Settings', 'the-post-grid' ),
149 __( 'Settings', "the-post-grid" ),
150 'administrator',
151 'rttpg_settings',
152 [ &$this, 'settings' ] );
153
154 add_submenu_page( 'edit.php?post_type=' . rtTPG()->post_type,
155 __( 'Get Help' ),
156 __( 'Get Help', "the-post-grid" ),
157 'administrator',
158 'rttpg_get_help',
159 [
160 $this,
161 'get_help',
162 ] );
163 }
164
165 function get_help() {
166 Fns::view('page.help');
167 }
168
169 public function settings() {
170 Fns::view( 'settings.settings' );
171 }
172
173 }