PluginProbe
Meow Gallery / 4.2.1
Meow Gallery v4.2.1
5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 All 156 releases
meow-gallery / common / admin.php

admin.php in Meow Gallery 4.2.1, at common/admin.php

174 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !class_exists( 'MeowCommon_Admin' ) ) {
4
5 class MeowCommon_Admin {
6
7 public static $loaded = false;
8 public static $version = "3.5";
9 public static $admin_version = "3.5";
10
11 public $prefix; // prefix used for actions, filters (mfrh)
12 public $mainfile; // plugin main file (media-file-renamer.php)
13 public $domain; // domain used for translation (media-file-renamer)
14 public $isPro = false;
15
16 public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
17
18 public function __construct( $prefix, $mainfile, $domain, $isPro = false, $disableReview = false, $freeOnly = false ) {
19
20 if ( !MeowCommon_Admin::$loaded ) {
21 if ( is_admin() ) {
22
23 // Check potential issues with this WordPress install, other plugins, etc.
24 new MeowCommon_Classes_Issues( $prefix, $mainfile, $domain );
25
26 // Create the Meow Apps Menu
27 add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
28 if ( isset( $_GET['page'] ) && $_GET['page'] === 'meowapps-main-menu' ) {
29 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 100000, 1 );
30 }
31 }
32 MeowCommon_Admin::$loaded = true;
33 }
34
35 // Variables for this plugin
36 $this->prefix = $prefix;
37 $this->mainfile = $mainfile;
38 $this->domain = $domain;
39 $this->isPro = $isPro;
40
41 // If there is no mainfile, it's either a Pro only Plugin (with no Free version available) or a Theme.
42 if ( is_admin() ) {
43 $license = get_option( $this->prefix . '_license', "" );
44 if ( !empty( $license ) && !$this->isPro ) {
45 add_action( 'admin_notices', array( $this, 'admin_notices_licensed_free' ) );
46 }
47 if ( !$disableReview ) {
48 new MeowCommon_Classes_Ratings( $prefix, $mainfile, $domain );
49 }
50 }
51 add_filter( 'plugin_row_meta', array( $this, 'custom_plugin_row_meta' ), 10, 2 );
52 add_filter( 'edd_sl_api_request_verify_ssl', array( $this, 'request_verify_ssl' ), 10, 0 );
53 }
54
55 function custom_plugin_row_meta( $links, $file ) {
56 $path = pathinfo( $file );
57 $pathName = basename( $path['dirname'] );
58 $thisPath = pathinfo( $this->mainfile );
59 $thisPathName = basename( $thisPath['dirname'] );
60 $isActive = is_plugin_active( $file );
61 if ( !$isActive ) {
62 return $links;
63 }
64 $isIssue = $this->isPro && !$this->is_registered();
65 if ( strpos( $pathName, $thisPathName ) !== false ) {
66 $new_links = array(
67 'settings' =>
68 sprintf( __( '<a href="admin.php?page=%s_settings">Settings</a>', $this->domain ), $this->prefix ),
69 'license' =>
70 $this->is_registered() ?
71 ('<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>') :
72 ( $isIssue ? (sprintf( '<span style="color: #ff3434;">' . __( 'License Issue', $this->domain ), $this->prefix ) . '</span>') : (sprintf( '<span>' . __( '<a target="_blank" href="https://store.meowapps.com">Get the <u>Pro Version</u></a>', $this->domain ), $this->prefix ) . '</span>') ),
73 );
74 $links = array_merge( $new_links, $links );
75 }
76 return $links;
77 }
78
79 function request_verify_ssl() {
80 return get_option( 'force_sslverify', false );
81 }
82
83 function nice_name_from_file( $file ) {
84 $info = pathinfo( $file );
85 if ( !empty( $info ) ) {
86 if ( $info['filename'] == 'wplr-sync' ) {
87 return "WP/LR Sync";
88 }
89 $info['filename'] = str_replace( '-', ' ', $info['filename'] );
90 $file = ucwords( $info['filename'] );
91 }
92 return $file;
93 }
94
95 function admin_notices_licensed_free() {
96 if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) {
97 delete_option( $this->prefix . '_pro_serial' );
98 delete_option( $this->prefix . '_license' );
99 return;
100 }
101 echo '<div class="notice notice-error">';
102 printf(
103 __( '<p>It looks like you are using the free version of the plugin (<b>%s</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.', $this->domain ),
104 $this->nice_name_from_file( $this->mainfile ) );
105 echo '<p>
106 <form method="post" action="">
107 <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
108 <input type="submit" name="submit" id="submit" class="button" value="'
109 . __( 'Remove the license', $this->domain ) . '">
110 </form>
111 </p>
112 ';
113 echo '</div>';
114 }
115
116 function admin_menu_start() {
117 // Hide the admin if user doesn't like Meow much
118 if ( get_option( 'meowapps_hide_meowapps', false ) ) {
119 register_setting( 'general', 'meowapps_hide_meowapps' );
120 add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
121 return;
122 }
123
124 // Create standard menu if it does not already exist
125 global $submenu;
126 if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
127 add_menu_page( 'Meow Apps', '<img alt="Meow Apps" style="width: 24px; margin-left: -30px; position: absolute; margin-top: -3px;" src="' . MeowCommon_Admin::$logo . '" />Meow Apps', 'manage_options', 'meowapps-main-menu',
128 array( $this, 'admin_meow_apps' ), '', 82 );
129 add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', $this->domain ),
130 __( 'Dashboard', $this->domain ), 'manage_options',
131 'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
132 }
133 }
134
135 function meowapps_hide_dashboard_callback() {
136 $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
137 checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
138 $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
139 echo wp_kses_post( $html );
140 }
141
142 function is_registered() {
143 return apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix );
144 }
145
146 function get_phpinfo() {
147 ob_start();
148 phpinfo( INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES );
149 $html = ob_get_contents();
150 ob_end_clean();
151 $html = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $html );
152 echo wp_kses_post( $html );
153 }
154
155 function admin_meow_apps() {
156 echo "<div id='meow-common-dashboard'></div>";
157 echo "<div style='display: none;' id='meow-common-phpinfo'>";
158 echo wp_kses_post( $this->get_phpinfo() );
159 echo "</div>";
160 }
161
162 function admin_footer_text( $current ) {
163 return sprintf(
164 // translators: %1$s is the version of the interface; %2$s is a file path.
165 __( 'Thanks for using <a href="https://meowapps.com">Meow Apps</a>! This is the Meow Admin %1$s <br /><i>Loaded from %2$s </i>', $this->domain ),
166 MeowCommon_Admin::$version,
167 __FILE__
168 );
169 }
170 }
171 }
172
173 ?>
174