PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.12
Code Manager v1.0.12
1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / code-manager.php
code-manager Last commit date
Code_Manager 4 years ago admin 4 years ago assets 4 years ago freemius 4 years ago includes 4 years ago public 4 years ago vendor 4 years ago .gitignore 4 years ago CHANGES.md 4 years ago LICENSE.txt 4 years ago README.md 4 years ago code-manager-config.php 4 years ago code-manager.php 4 years ago composer.json 4 years ago readme.txt 4 years ago todo.txt 4 years ago
code-manager.php
237 lines
1 <?php
2
3 /**
4 * Plugin Name: Code Manager
5 * Plugin URI: https://code-manager.com/
6 * Description: Create, edit and organize PHP, JavaScript, CSS and HTML code from your WordPress dashboard.
7 * Version: 1.0.12
8 * Author: Passionate Programmers B.V.
9 * Author URI: https://code-manager.com/
10 * Text Domain: code-manager
11 * License:
12 * License URI:
13 * Domain Path: /languages
14 *
15 * @author Peter Schulz
16 * @since 1.0.0
17 */
18 if ( !defined( 'WPINC' ) ) {
19 die;
20 }
21 if ( !defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 if ( function_exists( 'code_manager_fs' ) ) {
26 code_manager_fs()->set_basename( false, __FILE__ );
27 } else {
28 // Load namespaces
29 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
30 // Set plugin version
31 // Needs to be defined before activation, deactivation and uninstall hooks
32 if ( !defined( 'CODE_MANAGER_VERSION' ) ) {
33 define( 'CODE_MANAGER_VERSION', '1.0.12' );
34 }
35 // Create a helper function for easy SDK access.
36 function code_manager_fs()
37 {
38 global $code_manager_fs ;
39
40 if ( !isset( $code_manager_fs ) ) {
41 // Include Freemius SDK.
42 require_once dirname( __FILE__ ) . '/freemius/start.php';
43 $code_manager_fs = fs_dynamic_init( array(
44 'id' => '6331',
45 'slug' => 'code-manager',
46 'type' => 'plugin',
47 'public_key' => 'pk_7a949f640a340d0addeee391d19d6',
48 'is_premium' => false,
49 'premium_suffix' => 'Premium',
50 'has_addons' => false,
51 'has_paid_plans' => true,
52 'trial' => array(
53 'days' => 14,
54 'is_require_payment' => false,
55 ),
56 'menu' => array(
57 'slug' => 'code_manager',
58 'contact' => false,
59 ),
60 'is_live' => true,
61 ) );
62 }
63
64 return $code_manager_fs;
65 }
66
67 // Init Freemius.
68 code_manager_fs();
69 // Signal that SDK was initiated.
70 do_action( 'code_manager_fs_loaded' );
71 /**
72 * Activate plugin
73 *
74 * @author Peter Schulz
75 * @since 1.0.0
76 */
77 function activate_code_manager()
78 {
79 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager-switch.php';
80 Code_Manager_Switch::activate();
81 register_uninstall_hook( __FILE__, 'code_manager_uninstall' );
82 }
83
84 register_activation_hook( __FILE__, 'activate_code_manager' );
85 /**
86 * Deactivate plugin
87 *
88 * @author Peter Schulz
89 * @since 1.0.0
90 */
91 function deactivate_code_manager()
92 {
93 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager-switch.php';
94 Code_Manager_Switch::deactivate();
95 }
96
97 register_deactivation_hook( __FILE__, 'deactivate_code_manager' );
98 /**
99 * Uninstall blog
100 *
101 * This functions is called when the plugin is uninstalled. The following actions are performed:
102 * + Drop plugin tables (unless settings indicate not to)
103 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
104 *
105 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
106 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
107 *
108 * @author Peter Schulz
109 * @since 1.0.0
110 */
111 function code_manager_uninstall_blog()
112 {
113 global $wpdb ;
114 $wpdb->suppress_errors( true );
115 $drop_tables = get_option( 'code_manager_uninstall_tables' );
116
117 if ( !$drop_tables || 'on' === $drop_tables ) {
118 $drop_table = "drop table if exists {wp_prefix}code_manager;";
119 $wpdb->query( str_replace( '{wp_prefix}', $wpdb->prefix, $drop_table ) );
120 }
121
122 $delete_options = get_option( 'code_manager_uninstall_options' );
123
124 if ( !$delete_options || 'on' === $delete_options ) {
125 // Delete Code Manager options
126 $wpdb->query( "delete from {$wpdb->options} where option_name like 'code_manager_%'" );
127 // db call ok; no-cache ok.
128 }
129
130 }
131
132 /**
133 * Uninstall plugin
134 *
135 * @author Peter Schulz
136 * @since 1.0.0
137 */
138 function code_manager_uninstall()
139 {
140
141 if ( is_multisite() ) {
142 global $wpdb ;
143 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options)
144 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
145 // db call ok; no-cache ok.
146 foreach ( $blogids as $blog_id ) {
147 // Uninstall blog.
148 switch_to_blog( $blog_id );
149 code_manager_uninstall_blog();
150 restore_current_blog();
151 }
152 } else {
153 // Uninstall single site installation
154 code_manager_uninstall_blog();
155 }
156
157 code_manager_fs()->add_action( 'after_uninstall', 'code_manager_fs_uninstall_cleanup' );
158 }
159
160 /**
161 * Remove preview code ids on login
162 *
163 * @since 1.0.0
164 */
165 function wpda_remove_user_preview_codes_on_login( $user_login )
166 {
167 $user = get_user_by( 'login', $user_login );
168 $user_id = $user->ID;
169 delete_user_meta( $user_id, 'code_manager_preview_code_ids' );
170 }
171
172 add_action( 'wp_login', 'wpda_remove_user_preview_codes_on_login', 99 );
173 /**
174 * Remove preview code ids on logout
175 *
176 * @since 1.0.0
177 */
178 function wpda_remove_user_preview_codes_on_logout( $user_id )
179 {
180 delete_user_meta( $user_id, 'code_manager_preview_code_ids' );
181 }
182
183 add_action( 'wp_logout', 'wpda_remove_user_preview_codes_on_logout', 10 );
184 // Send user to support page
185 function cm_support_forum_url( $wp_org_support_forum_url )
186 {
187 if ( code_manager_fs()->is_premium() ) {
188 // Use different support page for premium version
189 return 'https://users.freemius.com/store/2612';
190 }
191 return 'https://wordpress.org/support/plugin/code-manager/';
192 }
193
194 code_manager_fs()->add_filter( 'support_forum_url', 'cm_support_forum_url' );
195 // Add Code Manager icon to freemius
196 function cm_freemius_icon()
197 {
198 return dirname( __FILE__ ) . '/freemius/assets/img/code-manager.png';
199 }
200
201 code_manager_fs()->add_filter( 'plugin_icon', 'cm_freemius_icon' );
202 // Handle freemius menu items
203 function cm_freemius_menu_visible( $is_visible, $submenu_id )
204 {
205 // support, account, contact, pricing
206 if ( $submenu_id === 'contact' ) {
207 $is_visible = false;
208 }
209 if ( code_manager_fs()->is_premium() && $submenu_id === 'contact' ) {
210 $is_visible = true;
211 }
212 return $is_visible;
213 }
214
215 code_manager_fs()->add_filter(
216 'is_submenu_visible',
217 'cm_freemius_menu_visible',
218 10,
219 2
220 );
221 /**
222 * Start plugin after loading all other installed and activated plugins to get access to their libraries
223 *
224 * @author Peter Schulz
225 * @since 1.0.0
226 */
227 function run_code_manager()
228 {
229 require_once plugin_dir_path( __FILE__ ) . 'code-manager-config.php';
230 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager.php';
231 $code_manager = new Code_Manager();
232 $code_manager->run();
233 }
234
235 add_action( 'plugins_loaded', 'run_code_manager' );
236 }
237