Insert PHP Code Snippet - Version 1.2.4

Version Description

  • Removed deprecated widget initializing function
Download this release

Release Info

Developer f1logic
Plugin Icon 128x128 Insert PHP Code Snippet
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

add_shortcode_tynimce.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) )
3
- exit;
4
-
5
- if(!class_exists('XYZ_Insert_Php_TinyMCESelector')):
6
-
7
- class XYZ_Insert_Php_TinyMCESelector{
8
- var $buttonName = 'xyz_ips_snippet_selecter';
9
- function addSelector(){
10
- // Don't bother doing this stuff if the current user lacks permissions
11
- if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
12
- return;
13
-
14
- // Add only in Rich Editor mode
15
- if ( get_user_option('rich_editing') == 'true') {
16
- add_filter('mce_external_plugins', array($this, 'registerTmcePlugin'));
17
- //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4
18
- //to add your button to other toolbars of your tinymce
19
- add_filter('mce_buttons', array($this, 'registerButton'));
20
- }
21
- }
22
-
23
- function registerButton($buttons){
24
- array_push($buttons, "separator", $this->buttonName);
25
- return $buttons;
26
- }
27
-
28
- function registerTmcePlugin($plugin_array){
29
- $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ips=editor_plugin_js';
30
- if ( get_user_option('rich_editing') == 'true')
31
- //var_dump($plugin_array);
32
- return $plugin_array;
33
- }
34
- }
35
-
36
- endif;
37
-
38
- if(!isset($shortcodesXYZEP)){
39
- $shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();
40
- add_action('admin_head', array($shortcodesXYZEP, 'addSelector'));
41
- }
42
-
43
- ?>
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
+
5
+ if(!class_exists('XYZ_Insert_Php_TinyMCESelector')):
6
+
7
+ class XYZ_Insert_Php_TinyMCESelector{
8
+ var $buttonName = 'xyz_ips_snippet_selecter';
9
+ function addSelector(){
10
+ // Don't bother doing this stuff if the current user lacks permissions
11
+ if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
12
+ return;
13
+
14
+ // Add only in Rich Editor mode
15
+ if ( get_user_option('rich_editing') == 'true') {
16
+ add_filter('mce_external_plugins', array($this, 'registerTmcePlugin'));
17
+ //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4
18
+ //to add your button to other toolbars of your tinymce
19
+ add_filter('mce_buttons', array($this, 'registerButton'));
20
+ }
21
+ }
22
+
23
+ function registerButton($buttons){
24
+ array_push($buttons, "separator", $this->buttonName);
25
+ return $buttons;
26
+ }
27
+
28
+ function registerTmcePlugin($plugin_array){
29
+ $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ips=editor_plugin_js';
30
+ if ( get_user_option('rich_editing') == 'true')
31
+ //var_dump($plugin_array);
32
+ return $plugin_array;
33
+ }
34
+ }
35
+
36
+ endif;
37
+
38
+ if(!isset($shortcodesXYZEP)){
39
+ $shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();
40
+ add_action('admin_head', array($shortcodesXYZEP, 'addSelector'));
41
+ }
42
+
43
+ ?>
admin/footer.php CHANGED
@@ -8,8 +8,8 @@ if(get_option('xyz_ips_premium_version_ads')==1){?>
8
  <div style="float: left; padding: 0 5px">
9
  <h2 style="vertical-align: middle;">
10
  <a target="_blank"
11
- href="https://xyzscripts.com/wordpress-plugins/xyz-wp-insert-code-snippet/details
12
- ">Fully Featured XYZ WP Insert Code Snippet Premium Plugin</a> - Just 19 USD
13
  </h2>
14
  </div>
15
  <div style="float: left; margin-top: 3px">
8
  <div style="float: left; padding: 0 5px">
9
  <h2 style="vertical-align: middle;">
10
  <a target="_blank"
11
+ href="https://xyzscripts.com/wordpress-plugins/xyz-wp-insert-code-snippet/details">Fully Featured XYZ WP Insert Code Snippet Premium Plugin</a>
12
+ - Just 19 USD
13
  </h2>
14
  </div>
15
  <div style="float: left; margin-top: 3px">
insert-php-code-snippet.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Insert PHP Code Snippet
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.3
7
  Author: xyzscripts.com
8
  Author URI: http://xyzscripts.com/
9
  Text Domain: insert-php-code-snippet
3
  Plugin Name: Insert PHP Code Snippet
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.4
7
  Author: xyzscripts.com
8
  Author URI: http://xyzscripts.com/
9
  Text Domain: insert-php-code-snippet
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Insert PHP Code Snippet ===
2
  Contributors: f1logic
3
- Donate link: http://xyzscripts.com/donate/
4
  Tags: insert PHP, add PHP, insert PHP code, insert PHP tag, insert PHP snippet, insert PHP code snippet , insert PHP snippet, add PHP code, insert PHP tag, add PHP snippet, add PHP code snippet, integrate PHP codes, raw PHP, embed PHP, PHP inserter, PHP code inserter, PHP snippet inserter
5
  Requires at least: 2.8
6
- Tested up to: 4.9.1
7
- Stable tag: 1.2.3
8
  License: GPLv2 or later
9
 
10
  Add PHP code to your pages and posts easily using shortcodes.
@@ -66,6 +66,9 @@ More questions ? [Drop a mail](http://xyzscripts.com/members/support/ "XYZScript
66
 
67
  == Changelog ==
68
 
 
 
 
69
  = 1.2.3 =
70
  * Option to enable auto insert of php opening tags added.
71
 
1
  === Insert PHP Code Snippet ===
2
  Contributors: f1logic
3
+ Donate link: http://xyzscripts.com/donate/
4
  Tags: insert PHP, add PHP, insert PHP code, insert PHP tag, insert PHP snippet, insert PHP code snippet , insert PHP snippet, add PHP code, insert PHP tag, add PHP snippet, add PHP code snippet, integrate PHP codes, raw PHP, embed PHP, PHP inserter, PHP code inserter, PHP snippet inserter
5
  Requires at least: 2.8
6
+ Tested up to: 4.9.4
7
+ Stable tag: 1.2.4
8
  License: GPLv2 or later
9
 
10
  Add PHP code to your pages and posts easily using shortcodes.
66
 
67
  == Changelog ==
68
 
69
+ = 1.2.4 =
70
+ * Removed deprecated widget initializing function
71
+
72
  = 1.2.3 =
73
  * Option to enable auto insert of php opening tags added.
74
 
shortcode-handler.php CHANGED
@@ -1,86 +1,86 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) )
3
- exit;
4
- global $wpdb;
5
- add_shortcode('xyz-ips','xyz_ips_display_content');
6
- function xyz_ips_display_content($xyz_snippet_name){
7
- global $wpdb;
8
- if(is_array($xyz_snippet_name)){
9
- $snippet_name = $xyz_snippet_name['snippet'];
10
- $query = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE title=%s" ,$snippet_name));
11
- if(count($query)>0){
12
- foreach ($query as $sippetdetails){
13
- if($sippetdetails->status==1){
14
- if(is_numeric(ini_get('output_buffering'))){
15
- $tmp=ob_get_contents();
16
- if(strlen($tmp)>0)
17
- ob_clean();
18
- ob_start();
19
- $content_to_eval=$sippetdetails->content;
20
-
21
- /***** to handle old codes : start *****/
22
-
23
- if(get_option('xyz_ips_auto_insert')==1){
24
- $xyz_ips_content_start='<?php';
25
- $new_line="\r\n";
26
- $xyz_ips_content_end='?>';
27
-
28
- if (stripos($content_to_eval, '<?php') !== false)
29
- $tag_start_position=stripos($content_to_eval,'<?php');
30
- else
31
- $tag_start_position="-1";
32
-
33
- if (stripos($content_to_eval, '?>') !== false)
34
- $tag_end_position=stripos($content_to_eval,'?>');
35
- else
36
- $tag_end_position="-1";
37
-
38
- if(stripos($content_to_eval, '<?php') === false && stripos($content_to_eval, '?>') === false)
39
- {
40
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
41
- }
42
- else if(stripos($content_to_eval, '<?php') !== false)
43
- {
44
- if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
45
- {
46
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
47
- }
48
- }
49
- else if(stripos($content_to_eval, '<?php') === false)
50
- {
51
- if (stripos($content_to_eval, '?>') !== false)
52
- {
53
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
54
- }
55
- }
56
- $content_to_eval='?>'.$content_to_eval;
57
- }
58
-
59
- /***** to handle old codes : end *****/
60
- else{
61
- if(substr(trim($content_to_eval), 0,5)=='<?php')
62
- $content_to_eval='?>'.$content_to_eval;
63
- }
64
-
65
- eval($content_to_eval);
66
- $xyz_em_content = ob_get_contents();
67
- ob_clean();
68
- echo $tmp;
69
- return $xyz_em_content;
70
- }
71
- else{
72
- eval($sippetdetails->content);
73
- }
74
- }
75
- else{
76
- return '';
77
- }
78
- break;
79
- }
80
- }
81
- else{
82
- return '';
83
- }
84
- }
85
- }
86
- add_filter('widget_text', 'do_shortcode'); // to run shortcodes in text widgets
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
+ global $wpdb;
5
+ add_shortcode('xyz-ips','xyz_ips_display_content');
6
+ function xyz_ips_display_content($xyz_snippet_name){
7
+ global $wpdb;
8
+ if(is_array($xyz_snippet_name)){
9
+ $snippet_name = $xyz_snippet_name['snippet'];
10
+ $query = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE title=%s" ,$snippet_name));
11
+ if(count($query)>0){
12
+ foreach ($query as $sippetdetails){
13
+ if($sippetdetails->status==1){
14
+ if(is_numeric(ini_get('output_buffering'))){
15
+ $tmp=ob_get_contents();
16
+ if(strlen($tmp)>0)
17
+ ob_clean();
18
+ ob_start();
19
+ $content_to_eval=$sippetdetails->content;
20
+
21
+ /***** to handle old codes : start *****/
22
+
23
+ if(get_option('xyz_ips_auto_insert')==1){
24
+ $xyz_ips_content_start='<?php';
25
+ $new_line="\r\n";
26
+ $xyz_ips_content_end='?>';
27
+
28
+ if (stripos($content_to_eval, '<?php') !== false)
29
+ $tag_start_position=stripos($content_to_eval,'<?php');
30
+ else
31
+ $tag_start_position="-1";
32
+
33
+ if (stripos($content_to_eval, '?>') !== false)
34
+ $tag_end_position=stripos($content_to_eval,'?>');
35
+ else
36
+ $tag_end_position="-1";
37
+
38
+ if(stripos($content_to_eval, '<?php') === false && stripos($content_to_eval, '?>') === false)
39
+ {
40
+ $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
41
+ }
42
+ else if(stripos($content_to_eval, '<?php') !== false)
43
+ {
44
+ if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
45
+ {
46
+ $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
47
+ }
48
+ }
49
+ else if(stripos($content_to_eval, '<?php') === false)
50
+ {
51
+ if (stripos($content_to_eval, '?>') !== false)
52
+ {
53
+ $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
54
+ }
55
+ }
56
+ $content_to_eval='?>'.$content_to_eval;
57
+ }
58
+
59
+ /***** to handle old codes : end *****/
60
+ else{
61
+ if(substr(trim($content_to_eval), 0,5)=='<?php')
62
+ $content_to_eval='?>'.$content_to_eval;
63
+ }
64
+
65
+ eval($content_to_eval);
66
+ $xyz_em_content = ob_get_contents();
67
+ ob_clean();
68
+ echo $tmp;
69
+ return $xyz_em_content;
70
+ }
71
+ else{
72
+ eval($sippetdetails->content);
73
+ }
74
+ }
75
+ else{
76
+ return '';
77
+ }
78
+ break;
79
+ }
80
+ }
81
+ else{
82
+ return '';
83
+ }
84
+ }
85
+ }
86
+ add_filter('widget_text', 'do_shortcode'); // to run shortcodes in text widgets
widget.php CHANGED
@@ -109,5 +109,10 @@ class Xyz_Insert_Php_Widget extends WP_Widget {
109
  <?php
110
  }
111
  } // end class Xyz_Insert_Php_Widget
112
- add_action('widgets_init', create_function('', 'return register_widget("Xyz_Insert_Php_Widget");'));
 
 
 
 
 
113
  ?>
109
  <?php
110
  }
111
  } // end class Xyz_Insert_Php_Widget
112
+
113
+ function xyz_ips_add_snippet_widget(){
114
+ register_widget("Xyz_Insert_Php_Widget");
115
+ }
116
+ add_action('widgets_init','xyz_ips_add_snippet_widget');
117
+
118
  ?>
xyz-functions.php CHANGED
@@ -1,53 +1,53 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) )
3
- exit;
4
-
5
- if(!function_exists('xyz_ips_plugin_get_version'))
6
- {
7
- function xyz_ips_plugin_get_version()
8
- {
9
- if ( ! function_exists( 'get_plugins' ) )
10
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
11
- $plugin_folder = get_plugins( '/' . plugin_basename( dirname( XYZ_INSERT_PHP_PLUGIN_FILE ) ) );
12
- return $plugin_folder['insert-php-code-snippet.php']['Version'];
13
- }
14
- }
15
-
16
- if(!function_exists('xyz_trim_deep'))
17
- {
18
-
19
- function xyz_trim_deep($value) {
20
- if ( is_array($value) ) {
21
- $value = array_map('xyz_trim_deep', $value);
22
- } elseif ( is_object($value) ) {
23
- $vars = get_object_vars( $value );
24
- foreach ($vars as $key=>$data) {
25
- $value->{$key} = xyz_trim_deep( $data );
26
- }
27
- } else {
28
- $value = trim($value);
29
- }
30
-
31
- return $value;
32
- }
33
-
34
- }
35
-
36
-
37
- if(!function_exists('xyz_ips_links')){
38
- function xyz_ips_links($links, $file) {
39
- $base = plugin_basename(XYZ_INSERT_PHP_PLUGIN_FILE);
40
- if ($file == $base) {
41
-
42
- $links[] = '<a href="https://xyzscripts.com/support/" class="xyz_support" title="Support"></a>';
43
- $links[] = '<a href="https://twitter.com/xyzscripts" class="xyz_twitt" title="Follow us on Twitter"></a>';
44
- $links[] = '<a href="https://www.facebook.com/xyzscripts" class="xyz_fbook" title="Like us on Facebook"></a>';
45
- $links[] = '<a href="https://plus.google.com/+Xyzscripts/" class="xyz_gplus" title="+1 us on Google+"></a>';
46
- $links[] = '<a href="https://www.linkedin.com/company/xyzscripts" class="xyz_linkedin" title="Follow us on LinkedIn"></a>';
47
- }
48
- return $links;
49
- }
50
- }
51
- add_filter( 'plugin_row_meta','xyz_ips_links',10,2);
52
-
53
  ?>
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
+
5
+ if(!function_exists('xyz_ips_plugin_get_version'))
6
+ {
7
+ function xyz_ips_plugin_get_version()
8
+ {
9
+ if ( ! function_exists( 'get_plugins' ) )
10
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
11
+ $plugin_folder = get_plugins( '/' . plugin_basename( dirname( XYZ_INSERT_PHP_PLUGIN_FILE ) ) );
12
+ return $plugin_folder['insert-php-code-snippet.php']['Version'];
13
+ }
14
+ }
15
+
16
+ if(!function_exists('xyz_trim_deep'))
17
+ {
18
+
19
+ function xyz_trim_deep($value) {
20
+ if ( is_array($value) ) {
21
+ $value = array_map('xyz_trim_deep', $value);
22
+ } elseif ( is_object($value) ) {
23
+ $vars = get_object_vars( $value );
24
+ foreach ($vars as $key=>$data) {
25
+ $value->{$key} = xyz_trim_deep( $data );
26
+ }
27
+ } else {
28
+ $value = trim($value);
29
+ }
30
+
31
+ return $value;
32
+ }
33
+
34
+ }
35
+
36
+
37
+ if(!function_exists('xyz_ips_links')){
38
+ function xyz_ips_links($links, $file) {
39
+ $base = plugin_basename(XYZ_INSERT_PHP_PLUGIN_FILE);
40
+ if ($file == $base) {
41
+
42
+ $links[] = '<a href="https://xyzscripts.com/support/" class="xyz_support" title="Support"></a>';
43
+ $links[] = '<a href="https://twitter.com/xyzscripts" class="xyz_twitt" title="Follow us on Twitter"></a>';
44
+ $links[] = '<a href="https://www.facebook.com/xyzscripts" class="xyz_fbook" title="Like us on Facebook"></a>';
45
+ $links[] = '<a href="https://plus.google.com/+Xyzscripts/" class="xyz_gplus" title="+1 us on Google+"></a>';
46
+ $links[] = '<a href="https://www.linkedin.com/company/xyzscripts" class="xyz_linkedin" title="Follow us on LinkedIn"></a>';
47
+ }
48
+ return $links;
49
+ }
50
+ }
51
+ add_filter( 'plugin_row_meta','xyz_ips_links',10,2);
52
+
53
  ?>