PluginProbe
Insert PHP Code Snippet / trunk
Insert PHP Code Snippet vtrunk
1.4.7 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 All 27 releases
← All changes | insert-php-code-snippet.php +74 -6 1.2trunk View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2 /*
3 3 Plugin Name: Insert PHP Code Snippet
4 4 Plugin URI: http://xyzscripts.com/wordpress-plugins/insert-php-code-snippet/
5 -Description: Insert and run PHP code in your pages and posts easily using shortcodes. This plugin lets you create a shortcode corresponding to any random PHP code and use the same in your posts, pages or widgets.
6 -Version: 1.2
5 +Description: Insert and run PHP code in your pages and posts easily using shortcodes. This plugin lets you create a shortcode for any PHP code and use it in your posts, pages, or widgets. It also includes flexible snippet placement options: Automatic, Execute on Demand, and Manual Shortcode.
6 +Version: 1.4.7
7 7 Author: xyzscripts.com
8 8 Author URI: http://xyzscripts.com/
9 9 Text Domain: insert-php-code-snippet
10 10 License: GPLv2 or later
@@ -29,11 +29,11 @@
29 29 // if ( !function_exists( 'add_action' ) ) {
30 30 // echo "Hi there! I'm just a plugin, not much I can do when called directly.";
31 31 // exit;
32 32 // }
33 +if ( ! defined( 'ABSPATH' ) )
34 + exit;
33 35
34 -ob_start();
35 -
36 36 //error_reporting(E_ALL);
37 37
38 38 define('XYZ_INSERT_PHP_PLUGIN_FILE',__FILE__);
39 39
@@ -54,10 +54,10 @@
54 54 require( dirname( __FILE__ ) . '/widget.php' );
55 55
56 56 require( dirname( __FILE__ ) . '/direct_call.php' );
57 57
58 +require_once( dirname( __FILE__ ) . '/admin/admin-notices.php' );
58 59
59 -
60 60 if(get_option('xyz_credit_link')=="ips"){
61 61
62 62 add_action('wp_footer', 'xyz_ips_credit');
63 63
@@ -65,7 +65,75 @@
65 65 function xyz_ips_credit() {
66 66 $content = '<div style="width:100%;text-align:center; font-size:11px; clear:both"><a target="_blank" title="Insert PHP Snippet Wordpress Plugin" href="http://xyzscripts.com/wordpress-plugins/insert-php-code-snippet/">PHP Code Snippets</a> Powered By : <a target="_blank" title="PHP Scripts & Wordpress Plugins" href="http://www.xyzscripts.com" >XYZScripts.com</a></div>';
67 67 echo $content;
68 68 }
69 +add_action('admin_init', 'xyz_ips_check_and_upgrade_plugin_version');
69 70
71 +function xyz_ips_check_and_upgrade_plugin_version() {
70 72
71 -?>
73 + $current_version = xyz_ips_plugin_get_version();
74 + $saved_version = get_option('xyz_ips_free_version');
75 + if ($saved_version === false) {
76 + xyz_ips_run_upgrade_routines();
77 + add_option('xyz_ips_free_version', $current_version);
78 + } elseif (version_compare($current_version, $saved_version, '>')) {
79 + xyz_ips_run_upgrade_routines();
80 + update_option('xyz_ips_free_version', $current_version);
81 + }
82 +}
83 +add_filter('plugin_action_links_' . plugin_basename(XYZ_INSERT_PHP_PLUGIN_FILE), 'xyz_ips_plugin_action_links');
84 +function xyz_ips_plugin_action_links($links) {
85 + if (isset($links['deactivate'])) {
86 + if (preg_match('/href=[\'"]([^\'"]+)[\'"]/', $links['deactivate'], $matches)) {
87 + $deactivation_url_ips = esc_url($matches[1]);
88 + $links['deactivate'] = '<a href="' . $deactivation_url_ips . '" class="xyz-ips-deactivate-link">Deactivate</a>';
89 + }
90 + }
91 + return $links;
92 +}
93 +add_action('admin_enqueue_scripts', 'xyz_ips_enqueue_modal_assets');
94 +function xyz_ips_enqueue_modal_assets($hook) {
95 + if ($hook !== 'plugins.php') return;
96 + // Output modal HTML
97 + add_action('admin_footer', 'xyz_ips_modal_html');
98 +}
99 +function xyz_ips_modal_html() {
100 + ?>
101 + <div id="xyz-ips-modal" class="xyz-ips-modal-overlay" style="display:none;">
102 + <div class="xyz-ips-modal-box">
103 + <h2>Are you sure you want to deactivate?</h2>
104 + <p>
105 + <span class="dashicons dashicons-warning" style="color: #d63638; font-size: 20px; vertical-align: middle;"></span>
106 + <strong> <u>Deleting</u> Insert PHP Code Snippet <u>afterward</u> will permanently remove all saved snippets, and any shortcodes using them will stop working.</strong>
107 + </p>
108 + <div class="xyz-ips-modal-buttons">
109 + <button id="xyz-ips-proceed-deactivate" class="button button-primary">Proceed to Deactivate</button>
110 + <button id="xyz-ips-cancel-deactivate" class="button">Cancel</button>
111 + </div>
112 + </div>
113 + </div>
114 + <?php
115 +}
116 +if (get_option('xyz_ips_sync_needed') == 0)
117 +{
118 +// --- update manual shortcode counts ---
119 +add_action('save_post', function($post_id, $post) {
120 + if (wp_is_post_autosave($post_id)) return;
121 + if (wp_is_post_revision($post_id)) return;
122 + if (!$post) return;
123 + if ($post->post_status !== 'publish') {
124 + global $wpdb;
125 + $wpdb->delete($wpdb->prefix . 'xyz_ips_usage', ['post_id' => $post_id]);
126 + return;
127 + }
128 + xyz_ips_update_usage_for_post(
129 + $post_id,
130 + $post->post_content,
131 + $post->post_type
132 + );
133 +}, 10, 2);
134 +add_action('before_delete_post', function($post_id) {
135 + global $wpdb;
136 + $wpdb->delete($wpdb->prefix . 'xyz_ips_usage', ['post_id' => $post_id]);
137 +});
138 +}
139 +?>