PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.6
Code Manager v1.0.6
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 5 years ago admin 5 years ago assets 5 years ago freemius 5 years ago includes 5 years ago public 5 years ago vendor 5 years ago .gitignore 5 years ago CHANGES.md 5 years ago LICENSE.txt 5 years ago README.md 5 years ago code-manager-config.php 5 years ago code-manager.php 5 years ago composer.json 5 years ago readme.txt 5 years ago todo.txt 5 years ago
code-manager.php
236 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.6
8 * Author: Passionate Programmers
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.6' );
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 ),
59 'is_live' => true,
60 ) );
61 }
62
63 return $code_manager_fs;
64 }
65
66 // Init Freemius.
67 code_manager_fs();
68 // Signal that SDK was initiated.
69 do_action( 'code_manager_fs_loaded' );
70 /**
71 * Activate plugin
72 *
73 * @author Peter Schulz
74 * @since 1.0.0
75 */
76 function activate_code_manager()
77 {
78 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager-switch.php';
79 Code_Manager_Switch::activate();
80 register_uninstall_hook( __FILE__, 'code_manager_uninstall' );
81 }
82
83 register_activation_hook( __FILE__, 'activate_code_manager' );
84 /**
85 * Deactivate plugin
86 *
87 * @author Peter Schulz
88 * @since 1.0.0
89 */
90 function deactivate_code_manager()
91 {
92 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager-switch.php';
93 Code_Manager_Switch::deactivate();
94 }
95
96 register_deactivation_hook( __FILE__, 'deactivate_code_manager' );
97 /**
98 * Uninstall blog
99 *
100 * This functions is called when the plugin is uninstalled. The following actions are performed:
101 * + Drop plugin tables (unless settings indicate not to)
102 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
103 *
104 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
105 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
106 *
107 * @author Peter Schulz
108 * @since 1.0.0
109 */
110 function code_manager_uninstall_blog()
111 {
112 global $wpdb ;
113 $wpdb->suppress_errors( true );
114 $drop_tables = get_option( 'code_manager_uninstall_tables' );
115
116 if ( !$drop_tables || 'on' === $drop_tables ) {
117 $drop_table = "drop table if exists {wp_prefix}code_manager;";
118 $wpdb->query( str_replace( '{wp_prefix}', $wpdb->prefix, $drop_table ) );
119 }
120
121 $delete_options = get_option( 'code_manager_uninstall_options' );
122
123 if ( !$delete_options || 'on' === $delete_options ) {
124 // Delete Code Manager options
125 $wpdb->query( "delete from {$wpdb->options} where option_name like 'code_manager_%'" );
126 // db call ok; no-cache ok.
127 }
128
129 }
130
131 /**
132 * Uninstall plugin
133 *
134 * @author Peter Schulz
135 * @since 1.0.0
136 */
137 function code_manager_uninstall()
138 {
139
140 if ( is_multisite() ) {
141 global $wpdb ;
142 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options)
143 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
144 // db call ok; no-cache ok.
145 foreach ( $blogids as $blog_id ) {
146 // Uninstall blog.
147 switch_to_blog( $blog_id );
148 code_manager_uninstall_blog();
149 restore_current_blog();
150 }
151 } else {
152 // Uninstall single site installation
153 code_manager_uninstall_blog();
154 }
155
156 code_manager_fs()->add_action( 'after_uninstall', 'code_manager_fs_uninstall_cleanup' );
157 }
158
159 /**
160 * Remove preview code ids on login
161 *
162 * @since 1.0.0
163 */
164 function wpda_remove_user_preview_codes_on_login( $user_login )
165 {
166 $user = get_user_by( 'login', $user_login );
167 $user_id = $user->ID;
168 delete_user_meta( $user_id, 'code_manager_preview_code_ids' );
169 }
170
171 add_action( 'wp_login', 'wpda_remove_user_preview_codes_on_login', 99 );
172 /**
173 * Remove preview code ids on logout
174 *
175 * @since 1.0.0
176 */
177 function wpda_remove_user_preview_codes_on_logout( $user_id )
178 {
179 delete_user_meta( $user_id, 'code_manager_preview_code_ids' );
180 }
181
182 add_action( 'wp_logout', 'wpda_remove_user_preview_codes_on_logout', 10 );
183 // Send user to support page
184 function cm_support_forum_url( $wp_org_support_forum_url )
185 {
186 if ( code_manager_fs()->is_premium() ) {
187 // Use different support page for premium version
188 return 'https://users.freemius.com/store/2612';
189 }
190 return 'https://wordpress.org/support/plugin/code-manager/';
191 }
192
193 code_manager_fs()->add_filter( 'support_forum_url', 'cm_support_forum_url' );
194 // Add Code Manager icon to freemius
195 function cm_freemius_icon()
196 {
197 return dirname( __FILE__ ) . '/freemius/assets/img/code-manager.png';
198 }
199
200 code_manager_fs()->add_filter( 'plugin_icon', 'cm_freemius_icon' );
201 // Handle freemius menu items
202 function cm_freemius_menu_visible( $is_visible, $submenu_id )
203 {
204 // support, account, contact, pricing
205 if ( $submenu_id === 'contact' ) {
206 $is_visible = false;
207 }
208 if ( code_manager_fs()->is_premium() && $submenu_id === 'contact' ) {
209 $is_visible = true;
210 }
211 return $is_visible;
212 }
213
214 code_manager_fs()->add_filter(
215 'is_submenu_visible',
216 'cm_freemius_menu_visible',
217 10,
218 2
219 );
220 /**
221 * Start plugin after loading all other installed and activated plugins to get access to their libraries
222 *
223 * @author Peter Schulz
224 * @since 1.0.0
225 */
226 function run_code_manager()
227 {
228 require_once plugin_dir_path( __FILE__ ) . 'code-manager-config.php';
229 require_once plugin_dir_path( __FILE__ ) . 'includes/class-code-manager.php';
230 $code_manager = new Code_Manager();
231 $code_manager->run();
232 }
233
234 add_action( 'plugins_loaded', 'run_code_manager' );
235 }
236