Insert PHP Code Snippet - Version 1.2.3

Version Description

  • Option to enable auto insert of php opening tags added.
Download this release

Release Info

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

Code changes from version 1.2.2 to 1.2.3

admin/admin-notices.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- function wp_ips_admin_notice()
3
  {
4
  add_thickbox();
5
  $sharelink_text_array_ips = array
@@ -21,6 +21,10 @@ function wp_ips_admin_notice()
21
  );
22
  $sharelink_text_ips = array_rand($sharelink_text_array_ips, 1);
23
  $sharelink_text_ips = $sharelink_text_array_ips[$sharelink_text_ips];
 
 
 
 
24
 
25
 
26
  echo '<style>
@@ -39,12 +43,12 @@ $sharelink_text_ips = $sharelink_text_array_ips[$sharelink_text_ips];
39
  <p>
40
  <a href="https://wordpress.org/support/plugin/insert-php-code-snippet/reviews" class="button xyz_rate_btn" target="_blank">Rate it 5★\'s on wordpress</a>';
41
  if(get_option('xyz_credit_link')=="0")
42
- echo '<a class="button xyz_ips_backlink xyz_backlink_btn" target="_blank">Enable backlink</a>';
43
 
44
  echo '<a class="button xyz_share_btn" onclick=xyz_ips_shareon_tckbox();>Share on</a>
45
  <a href="https://xyzscripts.com/donate/5" class="button xyz_donate_btn" target="_blank">Donate</a>
46
 
47
- <a href="admin.php?page=insert-php-code-snippet-settings&ips_notice=hide" class="button xyz_show_btn">Don\'t Show This Again</a>
48
  </p>
49
 
50
  <div id="show_share_icons_ips" style="display: none;">
@@ -67,7 +71,7 @@ if($xyz_ips_installed_date < ( time() - (30*24*60*60) ))
67
  {
68
  if (get_option('xyz_ips_dnt_shw_notice') != "hide")
69
  {
70
- add_action('admin_notices', 'wp_ips_admin_notice');
71
  }
72
  }
73
  ?>
1
  <?php
2
+ function xyz_ips_admin_notice()
3
  {
4
  add_thickbox();
5
  $sharelink_text_array_ips = array
21
  );
22
  $sharelink_text_ips = array_rand($sharelink_text_array_ips, 1);
23
  $sharelink_text_ips = $sharelink_text_array_ips[$sharelink_text_ips];
24
+ $xyz_ips_link = admin_url('admin.php?page=insert-php-code-snippet-settings&ips_blink=en');
25
+ $xyz_ips_link = wp_nonce_url($xyz_ips_link,'ips-blk');
26
+ $xyz_ips_notice = admin_url('admin.php?page=insert-php-code-snippet-settings&ips_notice=hide');
27
+ $xyz_ips_notice = wp_nonce_url($xyz_ips_notice,'ips-shw');
28
 
29
 
30
  echo '<style>
43
  <p>
44
  <a href="https://wordpress.org/support/plugin/insert-php-code-snippet/reviews" class="button xyz_rate_btn" target="_blank">Rate it 5★\'s on wordpress</a>';
45
  if(get_option('xyz_credit_link')=="0")
46
+ echo '<a href="'.$xyz_ips_link.'" class="button xyz_backlink_btn xyz_blink">Enable Backlink</a>';
47
 
48
  echo '<a class="button xyz_share_btn" onclick=xyz_ips_shareon_tckbox();>Share on</a>
49
  <a href="https://xyzscripts.com/donate/5" class="button xyz_donate_btn" target="_blank">Donate</a>
50
 
51
+ <a href="'.$xyz_ips_notice.'" class="button xyz_show_btn">Don\'t Show This Again</a>
52
  </p>
53
 
54
  <div id="show_share_icons_ips" style="display: none;">
71
  {
72
  if (get_option('xyz_ips_dnt_shw_notice') != "hide")
73
  {
74
+ add_action('admin_notices', 'xyz_ips_admin_notice');
75
  }
76
  }
77
  ?>
admin/header.php CHANGED
@@ -13,6 +13,7 @@ if(isset($_POST['xyz_ips_pre_ads'])){
13
  update_option('xyz_ips_premium_version_ads',$xyz_ips_pre_ads);
14
  }
15
 
 
16
  if(get_option('xyz_ips_premium_version_ads')==1){
17
 
18
  ?>
@@ -25,7 +26,7 @@ if(get_option('xyz_ips_premium_version_ads')==1){
25
  </div>
26
  <div style="float: left; margin-top: 3px">
27
  <a target="_blank"
28
- href="https://xyzscripts.com/members/product/purchase/XYZWPICSPRE"><img
29
  src="<?php echo plugins_url("images/orange_buynow.png",XYZ_INSERT_PHP_PLUGIN_FILE); ?>">
30
  </a>
31
  </div>
@@ -35,7 +36,10 @@ if(get_option('xyz_ips_premium_version_ads')==1){
35
  </h2>
36
  </div>
37
  </div>
38
- <?php }
 
 
 
39
  if($_POST && isset($_POST['xyz_ips_credit']))
40
  {
41
  if (! isset( $_REQUEST['_wpnonce'] )|| ! wp_verify_nonce( $_REQUEST['_wpnonce'],'ips-psetting_')){
@@ -47,6 +51,25 @@ if($_POST && isset($_POST['xyz_ips_credit']))
47
  }
48
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  if((get_option('xyz_credit_link')=="0")&&(get_option('xyz_ips_credit_dismiss')=="0")){
52
  ?>
13
  update_option('xyz_ips_premium_version_ads',$xyz_ips_pre_ads);
14
  }
15
 
16
+ /*
17
  if(get_option('xyz_ips_premium_version_ads')==1){
18
 
19
  ?>
26
  </div>
27
  <div style="float: left; margin-top: 3px">
28
  <a target="_blank"
29
+ href="https://xyzscripts.com/members/product/purchase/XYZWPICSPRE"><img
30
  src="<?php echo plugins_url("images/orange_buynow.png",XYZ_INSERT_PHP_PLUGIN_FILE); ?>">
31
  </a>
32
  </div>
36
  </h2>
37
  </div>
38
  </div>
39
+ <?php
40
+ }
41
+ */
42
+
43
  if($_POST && isset($_POST['xyz_ips_credit']))
44
  {
45
  if (! isset( $_REQUEST['_wpnonce'] )|| ! wp_verify_nonce( $_REQUEST['_wpnonce'],'ips-psetting_')){
51
  }
52
 
53
 
54
+ if(!$_POST && isset($_GET['ips_blink'])&&isset($_GET['ips_blink'])=='en'){
55
+ if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'],'ips-blk')){
56
+ wp_nonce_ays( 'ips-blk');
57
+ exit;
58
+ }
59
+ update_option('xyz_credit_link',"ips");
60
+ ?>
61
+ <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
62
+ Thank you for enabling backlink.
63
+ &nbsp;&nbsp;&nbsp;<span id="xyz_system_notice_area_dismiss">Dismiss</span>
64
+ </div>
65
+
66
+ <style type="text/css">
67
+ .xyz_blink{
68
+ display:none !important;
69
+ }
70
+ </style>
71
+ <?php
72
+ }
73
 
74
  if((get_option('xyz_credit_link')=="0")&&(get_option('xyz_ips_credit_dismiss')=="0")){
75
  ?>
admin/install.php CHANGED
@@ -46,9 +46,13 @@ if (is_plugin_active($pluginName)) {
46
  add_option("xyz_ips_credit_dismiss",0);
47
  }
48
 
49
- if(get_option('xyz_ips_premium_version_ads')==""){
50
- add_option('xyz_ips_premium_version_ads',1);
51
- }
 
 
 
 
52
 
53
  $xyz_ips_installed_date = get_option('xyz_ips_installed_date');
54
  if ($xyz_ips_installed_date=="") {
46
  add_option("xyz_ips_credit_dismiss",0);
47
  }
48
 
49
+ if(get_option('xyz_ips_premium_version_ads')==""){
50
+ add_option('xyz_ips_premium_version_ads',1);
51
+ }
52
+
53
+ if(get_option('xyz_ips_auto_insert')==""){
54
+ add_option('xyz_ips_auto_insert',1);
55
+ }
56
 
57
  $xyz_ips_installed_date = get_option('xyz_ips_installed_date');
58
  if ($xyz_ips_installed_date=="") {
admin/settings.php CHANGED
@@ -1,134 +1,148 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) )
3
- exit;
4
 
5
  global $wpdb;
6
  // Load the options
7
- if(isset($_GET['ips_notice'])&& $_GET['ips_notice'] == 'hide')
8
- {
9
- update_option('xyz_ips_dnt_shw_notice', "hide");
10
- ?>
 
 
 
11
  <style type='text/css'>
12
- #ips_notice_td
13
- {
14
- display:none;
15
- }
16
  </style>
17
  <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
18
- Thanks again for using the plugin. We will never show the message again.
19
- &nbsp;&nbsp;&nbsp;<span
20
- id="xyz_system_notice_area_dismiss">Dismiss</span>
21
  </div>
22
  <?php
23
  }
24
- if($_POST){
25
 
26
- if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-psetting_' )) {
27
- wp_nonce_ays( 'ips-psetting_' );
28
- exit;
29
- }
30
- else {
31
-
32
- $_POST=xyz_trim_deep($_POST);
33
- $_POST = stripslashes_deep($_POST);
34
-
35
- $xyz_ips_pre_ads = intval($_POST['xyz_ips_pre_ads']);
36
 
37
- $xyz_ips_limit = abs(intval($_POST['xyz_ips_limit']));
38
- if($xyz_ips_limit==0)$xyz_ips_limit=20;
39
-
40
- $xyz_ips_credit = sanitize_text_field($_POST['xyz_ips_credit']);
41
- if(($xyz_ips_credit=="ips")||($xyz_ips_credit==0))
42
- update_option('xyz_ips_credit_link',$xyz_ips_credit);
43
 
44
- $xyz_ips_sortfield=sanitize_text_field($_POST['xyz_ips_sort_by_field']);
45
- if(($xyz_ips_sortfield=="id")||($xyz_ips_sortfield=="title"))
46
- update_option('xyz_ips_sort_field_name',$xyz_ips_sortfield);
47
 
48
- $xyz_ips_sortorder=sanitize_text_field($_POST['xyz_ips_sort_by_order']);
49
- if(($xyz_ips_sortorder=="asc")||($xyz_ips_sortorder=="desc"))
50
- update_option('xyz_ips_sort_order',$xyz_ips_sortorder);
51
-
52
- update_option('xyz_ips_limit',$xyz_ips_limit);
53
-
54
- ?>
55
-
56
- <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
57
- Settings updated successfully. &nbsp;&nbsp;&nbsp;<span id="xyz_system_notice_area_dismiss">Dismiss</span>
58
- </div>
59
- <?php
60
- }
61
- }
62
 
63
- ?>
 
64
 
65
- <div>
66
 
67
-
68
- <form method="post">
69
- <?php wp_nonce_field('ips-psetting_');?>
70
- <div style="float: left;width: 98%">
71
- <fieldset style=" width:100%; border:1px solid #F7F7F7; padding:10px 0px 15px 10px;">
72
- <legend ><h3>Settings</h3></legend>
73
- <table class="widefat" style="width:99%;">
74
-
75
- <tr valign="top">
76
- <td scope="row" ><label for="xyz_ihs_sort">Sorting of snippets</label>
77
- </td>
78
-
79
 
80
- <td>
81
- <select id="xyz_ips_sort_by_field" name="xyz_ips_sort_by_field" >
82
- <option value="id" <?php if(isset($_POST['xyz_ips_sort_by_field']) && $_POST['xyz_ips_sort_by_field']=='id'){echo 'selected';} else if(get_option('xyz_ips_sort_field_name')=="id"){echo 'selected';} ?>>Based on create time</option>
83
- <option value="title" <?php if(isset($_POST['xyz_ips_sort_by_field']) && $_POST['xyz_ips_sort_by_field']=='title'){ echo 'selected';}else if(get_option('xyz_ips_sort_field_name')=="title"){echo 'selected';} ?>>Based on name</option>
84
- </select>&nbsp;
85
- <select id="xyz_ips_sort_by_order" name="xyz_ips_sort_by_order" >
86
- <option value="desc" <?php if(isset($_POST['xyz_ips_sort_by_order']) && $_POST['xyz_ips_sort_by_order']=='desc'){echo 'selected';} else if(get_option('xyz_ips_sort_order')=="desc"){echo 'selected';} ?>>Descending</option>
87
- <option value="asc" <?php if(isset($_POST['xyz_ips_sort_by_order']) && $_POST['xyz_ips_sort_by_order']=='asc'){ echo 'selected';}else if(get_option('xyz_ips_sort_order')=="asc"){echo 'selected';} ?>>Ascending</option>
88
- </select>
89
-
90
- </td>
91
- </tr>
92
- <tr valign="top">
93
- <td scope="row" ><label for="xyz_ips_credit">Credit link to author</label>
94
- </td>
95
- <td><select name="xyz_ips_credit" id="xyz_ips_credit">
96
- <option value="ips"
97
- <?php selected(get_option('xyz_ips_credit_link'),"ips"); ?>>Enable</option>
98
- <option value="0"
99
- <?php if(get_option('xyz_ips_credit_link')!="ips"){echo 'selected';} ?>>Disable</option>
100
 
101
- </select>
102
- </td>
103
- </tr>
104
-
105
- <tr valign="top">
106
- <td scope="row" class=" settingInput" id=""><label for="xyz_ips_limit">Pagination limit</label></td>
107
- <td id=""><input name="xyz_ips_limit" type="text"
108
- id="xyz_ips_limit" value="<?php if(isset($_POST['xyz_ips_limit']) ){echo abs(intval($_POST['xyz_ips_limit']));}else{print(get_option('xyz_ips_limit'));} ?>" />
109
- </td>
110
- </tr>
111
- <tr valign="top">
112
- <td scope="row">
113
- <label for="xyz_ips_pre_ads">Premium Version Ads</label>
114
- </td>
115
- <td>
116
- <select name="xyz_ips_pre_ads" id="xyz_ips_pre_ads">
117
- <option value="0">Disable</option>
118
- <option value="1" <?php selected(get_option('xyz_ips_premium_version_ads'),1);?>>Enable</option>
119
- </select>
120
- </td>
121
- </tr>
122
- <tr valign="top">
123
- <td scope="row" class=" settingInput" id="xyz_ips_bottomBorderNone">
124
- </td>
125
- <td id="xyz_ips_bottomBorderNone"><input style="margin:10px 0 20px 0;" id="submit" class="button-primary xyz_ips_bottonWidth" type="submit" value=" Update Settings " />
126
- </td>
127
- </tr>
128
- </table>
129
- </fieldset>
130
-
131
- </div>
132
 
133
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  </div>
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
 
5
  global $wpdb;
6
  // Load the options
7
+ if(!$_POST && isset($_GET['ips_notice'])&& $_GET['ips_notice'] == 'hide'){
8
+ if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'],'ips-shw')){
9
+ wp_nonce_ays( 'ips-shw');
10
+ exit;
11
+ }
12
+ update_option('xyz_ips_dnt_shw_notice', "hide");
13
+ ?>
14
  <style type='text/css'>
15
+ #ips_notice_td{
16
+ display:none !important;
17
+ }
 
18
  </style>
19
  <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
20
+ Thanks again for using the plugin. We will never show the message again.
21
+ &nbsp;&nbsp;&nbsp;
22
+ <span id="xyz_system_notice_area_dismiss">Dismiss</span>
23
  </div>
24
  <?php
25
  }
 
26
 
27
+ if($_POST){
28
+ if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-psetting_' )) {
29
+ wp_nonce_ays( 'ips-psetting_' );
30
+ exit;
31
+ }
32
+ else{
33
+ $_POST=xyz_trim_deep($_POST);
34
+ $_POST = stripslashes_deep($_POST);
 
 
35
 
36
+ $xyz_ips_pre_ads = intval($_POST['xyz_ips_pre_ads']);
37
+ $xyz_ips_limit = abs(intval($_POST['xyz_ips_limit']));
 
 
 
 
38
 
39
+ if($xyz_ips_limit==0)$xyz_ips_limit=20;
40
+ $xyz_ips_credit = sanitize_text_field($_POST['xyz_ips_credit']);
 
41
 
42
+ if(($xyz_ips_credit=="ips")||($xyz_ips_credit==0))
43
+ update_option('xyz_credit_link',$xyz_ips_credit);
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ $xyz_ips_auto_insert = intval($_POST['xyz_ips_auto_insert']);
46
+ update_option('xyz_ips_auto_insert',$xyz_ips_auto_insert);
47
 
48
+ $xyz_ips_sortfield=sanitize_text_field($_POST['xyz_ips_sort_by_field']);
49
 
50
+ if(($xyz_ips_sortfield=="id")||($xyz_ips_sortfield=="title"))
51
+ update_option('xyz_ips_sort_field_name',$xyz_ips_sortfield);
 
 
 
 
 
 
 
 
 
 
52
 
53
+ $xyz_ips_sortorder=sanitize_text_field($_POST['xyz_ips_sort_by_order']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
+ if(($xyz_ips_sortorder=="asc")||($xyz_ips_sortorder=="desc"))
56
+ update_option('xyz_ips_sort_order',$xyz_ips_sortorder);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
+ update_option('xyz_ips_limit',$xyz_ips_limit);
59
+ ?>
60
+ <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
61
+ Settings updated successfully. &nbsp;&nbsp;&nbsp;
62
+ <span id="xyz_system_notice_area_dismiss">Dismiss</span>
63
+ </div>
64
+ <?php
65
+ }
66
+ }
67
+ ?>
68
+ <div>
69
+ <form method="post">
70
+ <?php wp_nonce_field('ips-psetting_');?>
71
+ <div style="float: left;width: 98%">
72
+ <fieldset style=" width:100%; border:1px solid #F7F7F7; padding:10px 0px 15px 10px;">
73
+ <legend >
74
+ <h3>Settings</h3>
75
+ </legend>
76
+ <table class="widefat" style="width:99%;">
77
+ <tr valign="top">
78
+ <td scope="row" >
79
+ <label for="xyz_ihs_sort">Sorting of snippets</label>
80
+ </td>
81
+ <td>
82
+ <select id="xyz_ips_sort_by_field" name="xyz_ips_sort_by_field" >
83
+ <option value="id" <?php if(isset($_POST['xyz_ips_sort_by_field']) && $_POST['xyz_ips_sort_by_field']=='id'){echo 'selected';} else if(get_option('xyz_ips_sort_field_name')=="id"){echo 'selected';} ?>>Based on create time</option>
84
+ <option value="title" <?php if(isset($_POST['xyz_ips_sort_by_field']) && $_POST['xyz_ips_sort_by_field']=='title'){ echo 'selected';}else if(get_option('xyz_ips_sort_field_name')=="title"){echo 'selected';} ?>>Based on name</option>
85
+ </select>
86
+ &nbsp;
87
+ <select id="xyz_ips_sort_by_order" name="xyz_ips_sort_by_order" >
88
+ <option value="desc" <?php if(isset($_POST['xyz_ips_sort_by_order']) && $_POST['xyz_ips_sort_by_order']=='desc'){echo 'selected';} else if(get_option('xyz_ips_sort_order')=="desc"){echo 'selected';} ?>>Descending</option>
89
+ <option value="asc" <?php if(isset($_POST['xyz_ips_sort_by_order']) && $_POST['xyz_ips_sort_by_order']=='asc'){ echo 'selected';}else if(get_option('xyz_ips_sort_order')=="asc"){echo 'selected';} ?>>Ascending</option>
90
+ </select>
91
+ </td>
92
+ </tr>
93
+ <tr valign="top">
94
+ <td scope="row" >
95
+ <label for="xyz_ips_credit">Credit link to author</label>
96
+ </td>
97
+ <td>
98
+ <select name="xyz_ips_credit" id="xyz_ips_credit">
99
+ <option value="ips"
100
+ <?php selected(get_option('xyz_credit_link'),"ips"); ?>>Enable</option>
101
+ <option value="0"
102
+ <?php if(get_option('xyz_credit_link')!="ips"){echo 'selected';} ?>>Disable</option>
103
+ </select>
104
+ </td>
105
+ </tr>
106
+ <tr valign="top">
107
+ <td scope="row" class="settingInput" id="">
108
+ <label for="xyz_ips_limit">Pagination limit</label>
109
+ </td>
110
+ <td id="">
111
+ <input name="xyz_ips_limit" type="text"
112
+ id="xyz_ips_limit" value="<?php if(isset($_POST['xyz_ips_limit']) ){echo abs(intval($_POST['xyz_ips_limit']));}else{print(get_option('xyz_ips_limit'));} ?>" />
113
+ </td>
114
+ </tr>
115
+ <tr valign="top">
116
+ <td scope="row">
117
+ <label for="xyz_ips_auto_insert">Autoinsert PHP opening tags</label>
118
+ </td>
119
+ <td>
120
+ <select name="xyz_ips_auto_insert" id="xyz_ips_auto_insert">
121
+ <option value="0" <?php selected(get_option('xyz_ips_auto_insert'),0);?>>Disable</option>
122
+ <option value="1" <?php selected(get_option('xyz_ips_auto_insert'),1);?>>Enable</option>
123
+ </select>
124
+ </td>
125
+ </tr>
126
+ <tr valign="top">
127
+ <td scope="row">
128
+ <label for="xyz_ips_pre_ads">Premium Version Ads</label>
129
+ </td>
130
+ <td>
131
+ <select name="xyz_ips_pre_ads" id="xyz_ips_pre_ads">
132
+ <option value="0" <?php selected(get_option('xyz_ips_premium_version_ads'),0);?>>Disable</option>
133
+ <option value="1" <?php selected(get_option('xyz_ips_premium_version_ads'),1);?>>Enable</option>
134
+ </select>
135
+ </td>
136
+ </tr>
137
+ <tr valign="top">
138
+ <td scope="row" class=" settingInput" id="xyz_ips_bottomBorderNone">
139
+ </td>
140
+ <td id="xyz_ips_bottomBorderNone">
141
+ <input style="margin:10px 0 20px 0;" id="submit" class="button-primary xyz_ips_bottonWidth" type="submit" value=" Update Settings " />
142
+ </td>
143
+ </tr>
144
+ </table>
145
+ </fieldset>
146
+ </div>
147
+ </form>
148
  </div>
admin/snippet-add.php CHANGED
@@ -1,64 +1,57 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) )
3
  exit;
 
4
  global $wpdb;
5
  $_POST = stripslashes_deep($_POST);
6
  $_POST = xyz_trim_deep($_POST);
7
  if(isset($_POST) && isset($_POST['addSubmit'])){
8
- if (
9
- ! isset( $_REQUEST['_wpnonce'] )
10
- || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-padd_' )
11
- ) {
12
  wp_nonce_ays( 'ips-padd_' );
13
  exit;
14
  }
 
15
  $temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
16
  $temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
17
  $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
18
  $xyz_ips_content = $_POST['snippetContent'];
 
19
  if($xyz_ips_title != "" && $xyz_ips_content != ""){
20
  if(ctype_alnum($temp_xyz_ips_title)){
21
  $snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE title=%s',$xyz_ips_title) ) ;
22
  if($snippet_count == 0){
23
 
24
- $xyz_ips_content_start='<?php';
25
- $new_line="\r\n";
26
- $xyz_ips_content_end='?>';
27
-
28
- if (stripos($xyz_ips_content, '<?php') !== false)
29
- $tag_start_position=stripos($xyz_ips_content,'<?php');
30
- else
31
- $tag_start_position="-1";
32
-
33
- if (stripos($xyz_ips_content, '?>') !== false)
34
- $tag_end_position=stripos($xyz_ips_content,'?>');
35
- else
36
- $tag_end_position="-1";
37
-
38
- //echo "<br>start-".$tag_start_position;
39
- //echo "<br>end-".$tag_end_position;
40
-
41
- if(stripos($xyz_ips_content, '<?php') === false && stripos($xyz_ips_content, '?>') === false)
42
- {
43
- $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
44
- }
45
- else if(stripos($xyz_ips_content, '<?php') !== false)
46
- {
47
- if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
48
- {
49
- $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
50
- }
51
- }
52
- else if(stripos($xyz_ips_content, '<?php') === false)
53
- {
54
  if (stripos($xyz_ips_content, '?>') !== false)
55
- {
56
- $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  }
59
 
60
 
61
-
62
  $xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
63
  $wpdb->insert($wpdb->prefix.'xyz_ips_short_code', array('title' =>$xyz_ips_title,'content'=>$xyz_ips_content,'short_code'=>$xyz_shortCode,'status'=>'1'),array('%s','%s','%s','%d'));
64
  header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=1'));
@@ -128,12 +121,25 @@ if(isset($_POST) && isset($_POST['addSubmit'])){
128
  </td>
129
  </tr>
130
  <tr>
131
- <td style="border-bottom: none;width:20%; ">
 
 
 
 
132
  &nbsp;&nbsp;&nbsp;PHP code
 
 
 
 
 
 
 
 
133
  <font color="red">
134
  *
135
  </font>
136
  </td>
 
137
  <td style="border-bottom: none;width:1px;">
138
  &nbsp;:&nbsp;
139
  </td>
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) )
3
  exit;
4
+
5
  global $wpdb;
6
  $_POST = stripslashes_deep($_POST);
7
  $_POST = xyz_trim_deep($_POST);
8
  if(isset($_POST) && isset($_POST['addSubmit'])){
9
+ if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce($_REQUEST['_wpnonce'],'ips-padd_')){
 
 
 
10
  wp_nonce_ays( 'ips-padd_' );
11
  exit;
12
  }
13
+
14
  $temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
15
  $temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
16
  $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
17
  $xyz_ips_content = $_POST['snippetContent'];
18
+
19
  if($xyz_ips_title != "" && $xyz_ips_content != ""){
20
  if(ctype_alnum($temp_xyz_ips_title)){
21
  $snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE title=%s',$xyz_ips_title) ) ;
22
  if($snippet_count == 0){
23
 
24
+ if(get_option('xyz_ips_auto_insert')==1){
25
+ $xyz_ips_content_start='<?php';
26
+ $new_line="\r\n";
27
+ $xyz_ips_content_end='?>';
28
+
29
+ if (stripos($xyz_ips_content, '<?php') !== false)
30
+ $tag_start_position=stripos($xyz_ips_content,'<?php');
31
+ else
32
+ $tag_start_position="-1";
33
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  if (stripos($xyz_ips_content, '?>') !== false)
35
+ $tag_end_position=stripos($xyz_ips_content,'?>');
36
+ else
37
+ $tag_end_position="-1";
38
+
39
+ if(stripos($xyz_ips_content, '<?php') === false && stripos($xyz_ips_content, '?>') === false){
40
+ $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
41
+ }
42
+ else if(stripos($xyz_ips_content, '<?php') !== false){
43
+ if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position){
44
+ $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
45
+ }
46
+ }
47
+ else if(stripos($xyz_ips_content, '<?php') === false){
48
+ if (stripos($xyz_ips_content, '?>') !== false){
49
+ $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
50
+ }
51
  }
52
  }
53
 
54
 
 
55
  $xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
56
  $wpdb->insert($wpdb->prefix.'xyz_ips_short_code', array('title' =>$xyz_ips_title,'content'=>$xyz_ips_content,'short_code'=>$xyz_shortCode,'status'=>'1'),array('%s','%s','%s','%d'));
57
  header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=1'));
121
  </td>
122
  </tr>
123
  <tr>
124
+
125
+ <td style="border-bottom: none;width:20%;">
126
+ <?php
127
+ if(get_option('xyz_ips_auto_insert')==1){
128
+ ?>
129
  &nbsp;&nbsp;&nbsp;PHP code
130
+ <?php
131
+ }
132
+ else{
133
+ ?>
134
+ &nbsp;&nbsp;&nbsp;PHP code (without &lt;?php ?&gt;)&nbsp;
135
+ <?php
136
+ }
137
+ ?>
138
  <font color="red">
139
  *
140
  </font>
141
  </td>
142
+
143
  <td style="border-bottom: none;width:1px;">
144
  &nbsp;:&nbsp;
145
  </td>
admin/snippet-edit.php CHANGED
@@ -32,6 +32,7 @@ if(isset($_POST) && isset($_POST['updateSubmit'])){
32
  $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
33
  $xyz_ips_content = $_POST['snippetContent'];
34
 
 
35
  $xyz_ips_content_start='<?php';
36
  $new_line="\r\n";
37
  $xyz_ips_content_end='?>';
@@ -46,9 +47,7 @@ if(isset($_POST) && isset($_POST['updateSubmit'])){
46
  else
47
  $tag_end_position="-1";
48
 
49
- //echo "<br>start-".$tag_start_position;
50
- //echo "<br>end-".$tag_end_position;
51
-
52
  if(stripos($xyz_ips_content, '<?php') === false && stripos($xyz_ips_content, '?>') === false)
53
  {
54
  $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
@@ -67,6 +66,7 @@ if(isset($_POST) && isset($_POST['updateSubmit'])){
67
  $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
68
  }
69
  }
 
70
 
71
  if($xyz_ips_title != "" && $xyz_ips_content != ""){
72
  if(ctype_alnum($temp_xyz_ips_title)){
@@ -144,13 +144,23 @@ $snippetDetails = $snippetDetails[0];
144
  <td>
145
  <input style="width:80%;"
146
  type="text" name="snippetTitle" id="snippetTitle"
147
- value="
148
- <?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>">
149
  </td>
150
  </tr>
151
  <tr>
152
  <td style="border-bottom: none;width:20%; ">
153
- &nbsp;&nbsp;&nbsp;PHP code
 
 
 
 
 
 
 
 
 
 
 
154
  <font color="red">
155
  *
156
  </font>
32
  $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
33
  $xyz_ips_content = $_POST['snippetContent'];
34
 
35
+ if(get_option('xyz_ips_auto_insert')==1){
36
  $xyz_ips_content_start='<?php';
37
  $new_line="\r\n";
38
  $xyz_ips_content_end='?>';
47
  else
48
  $tag_end_position="-1";
49
 
50
+
 
 
51
  if(stripos($xyz_ips_content, '<?php') === false && stripos($xyz_ips_content, '?>') === false)
52
  {
53
  $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
66
  $xyz_ips_content=$xyz_ips_content_start.$new_line.$xyz_ips_content;
67
  }
68
  }
69
+ }
70
 
71
  if($xyz_ips_title != "" && $xyz_ips_content != ""){
72
  if(ctype_alnum($temp_xyz_ips_title)){
144
  <td>
145
  <input style="width:80%;"
146
  type="text" name="snippetTitle" id="snippetTitle"
147
+ value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>">
 
148
  </td>
149
  </tr>
150
  <tr>
151
  <td style="border-bottom: none;width:20%; ">
152
+ <?php
153
+ if(get_option('xyz_ips_auto_insert')==1){
154
+ ?>
155
+ &nbsp;&nbsp;&nbsp;PHP code
156
+ <?php
157
+ }
158
+ else{
159
+ ?>
160
+ &nbsp;&nbsp;&nbsp;PHP code (without &lt;?php ?&gt;)&nbsp;
161
+ <?php
162
+ }
163
+ ?>
164
  <font color="red">
165
  *
166
  </font>
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.2
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.3
7
  Author: xyzscripts.com
8
  Author URI: http://xyzscripts.com/
9
  Text Domain: insert-php-code-snippet
readme.txt CHANGED
@@ -1,11 +1,10 @@
1
  === Insert PHP Code Snippet ===
2
  Contributors: f1logic
3
  Donate link: http://xyzscripts.com/donate/
4
-
5
  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
6
  Requires at least: 2.8
7
  Tested up to: 4.9.1
8
- Stable tag: 1.2.2
9
  License: GPLv2 or later
10
 
11
  Add PHP code to your pages and posts easily using shortcodes.
@@ -67,6 +66,9 @@ More questions ? [Drop a mail](http://xyzscripts.com/members/support/ "XYZScript
67
 
68
  == Changelog ==
69
 
 
 
 
70
  = 1.2.2 =
71
  * Automatic detection and correction of php opening and closing tags in snippet
72
  * Updated nonces and validations
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
 
67
  == Changelog ==
68
 
69
+ = 1.2.3 =
70
+ * Option to enable auto insert of php opening tags added.
71
+
72
  = 1.2.2 =
73
  * Automatic detection and correction of php opening and closing tags in snippet
74
  * Updated nonces and validations
shortcode-handler.php CHANGED
@@ -13,53 +13,54 @@ function xyz_ips_display_content($xyz_snippet_name){
13
  if($sippetdetails->status==1){
14
  if(is_numeric(ini_get('output_buffering'))){
15
  $tmp=ob_get_contents();
16
- ob_clean();
 
17
  ob_start();
18
  $content_to_eval=$sippetdetails->content;
19
 
20
  /***** to handle old codes : start *****/
21
 
22
- $xyz_ips_content_start='<?php';
23
- $new_line="\r\n";
24
- $xyz_ips_content_end='?>';
25
-
26
- if (stripos($content_to_eval, '<?php') !== false)
27
- $tag_start_position=stripos($content_to_eval,'<?php');
28
- else
29
- $tag_start_position="-1";
30
 
31
- if (stripos($content_to_eval, '?>') !== false)
32
- $tag_end_position=stripos($content_to_eval,'?>');
33
- else
34
- $tag_end_position="-1";
35
 
36
- //echo "<br>start-".$tag_start_position;
37
- //echo "<br>end-".$tag_end_position;
 
 
38
 
39
- if(stripos($content_to_eval, '<?php') === false && stripos($content_to_eval, '?>') === false)
40
- {
41
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
42
- }
43
- else if(stripos($content_to_eval, '<?php') !== false)
44
- {
45
- if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
46
  {
47
  $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
48
  }
49
- }
50
- else if(stripos($content_to_eval, '<?php') === false)
51
- {
52
- if (stripos($content_to_eval, '?>') !== false)
53
  {
54
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
 
 
 
55
  }
 
 
 
 
 
 
 
 
56
  }
57
 
58
  /***** to handle old codes : end *****/
59
-
60
-
61
-
62
- $content_to_eval='?>'.$content_to_eval;
63
 
64
  eval($content_to_eval);
65
  $xyz_em_content = ob_get_contents();
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();
widget.php CHANGED
@@ -1,139 +1,113 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) )
3
- exit;
4
  /**
5
- * XYZScripts Insert PHP Snippet Widget Class
6
- */
7
-
8
  ////*****************************Sidebar Widget**********************************////
9
-
10
  class Xyz_Insert_Php_Widget extends WP_Widget {
11
-
12
-
13
  /** constructor -- name this the same as the class above */
14
  function __construct() {
15
  parent::__construct(false, $name = 'Insert PHP Snippet');
16
  }
17
-
18
  /** @see WP_Widget::widget -- do not rename this */
19
- function widget($args, $instance) {
20
  extract( $args );
21
  global $wpdb;
22
- $title = apply_filters('widget_title', $instance['title']);
23
- $xyz_ips_id = $instance['message'];
24
-
25
- $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ips_short_code WHERE id=%d",$xyz_ips_id ));
26
-
27
  $entry = $entries[0];
28
-
29
  echo $before_widget;
30
  if ( $title )
31
- echo $before_title . $title . $after_title;
32
-
33
- $content_to_eval=$entry->content;
34
-
35
-
36
- /***** to handle old codes : start *****/
37
-
38
- $xyz_ips_content_start='<?php';
39
- $new_line="\r\n";
40
- $xyz_ips_content_end='?>';
41
-
42
- if (stripos($content_to_eval, '<?php') !== false)
43
- $tag_start_position=stripos($content_to_eval,'<?php');
44
- else
45
- $tag_start_position="-1";
46
-
47
- if (stripos($content_to_eval, '?>') !== false)
48
- $tag_end_position=stripos($content_to_eval,'?>');
49
- else
50
- $tag_end_position="-1";
51
-
52
- //echo "<br>start-".$tag_start_position;
53
- //echo "<br>end-".$tag_end_position;
54
-
55
- if(stripos($content_to_eval, '<?php') === false && stripos($content_to_eval, '?>') === false)
56
- {
57
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
58
- }
59
- else if(stripos($content_to_eval, '<?php') !== false)
60
- {
61
- if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
62
- {
63
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
64
- }
65
- }
66
- else if(stripos($content_to_eval, '<?php') === false)
67
- {
68
- if (stripos($content_to_eval, '?>') !== false)
69
- {
70
- $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
71
- }
72
- }
73
-
74
- /***** to handle old codes : end *****/
75
-
76
  $content_to_eval='?>'.$content_to_eval;
77
-
78
- eval($content_to_eval);
79
-
 
 
 
 
 
80
  echo $after_widget;
81
-
82
  }
83
-
84
  /** @see WP_Widget::update -- do not rename this */
85
  function update($new_instance, $old_instance) {
86
- $instance = $old_instance;
87
- $instance['title'] = strip_tags($new_instance['title']);
88
- $instance['message'] = strip_tags($new_instance['message']);
89
  return $instance;
90
  }
91
-
92
  /** @see WP_Widget::form -- do not rename this */
93
  function form($instance) {
94
- global $wpdb;
95
- $entries = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status=%d ORDER BY id DESC",1 ));
96
-
97
-
98
- if(isset($instance['title'])){
99
- $title = esc_attr($instance['title']);
100
- }else{
101
- $title = '';
102
- }
103
-
104
- if(isset($instance['message'])){
105
- $message = esc_attr($instance['message']);
106
- }else{
107
- $message = '';
108
- }
109
-
 
 
 
 
 
 
 
 
 
110
  ?>
111
- <p>
112
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
113
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
114
- </p>
115
- <p>
116
- <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Choose Snippet :'); ?></label>
117
-
118
- <!-- <input class="widefat" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" type="text" value="<?php echo $message; ?>" />-->
119
- <select name="<?php echo $this->get_field_name('message'); ?>">
120
- <?php
121
- if( count($entries)>0 ) {
122
- $count=1;
123
- $class = '';
124
- foreach( $entries as $entry ) {
125
- ?>
126
- <option value="<?php echo $entry->id;?>" <?php if($message==$entry->id)echo "selected"; ?>><?php echo $entry->title;?></option>
127
- <?php
128
- }
129
- }
130
- ?>
131
- </select>
132
- </p>
133
  <?php
 
 
 
 
 
 
134
  }
135
-
136
-
137
  } // end class Xyz_Insert_Php_Widget
138
  add_action('widgets_init', create_function('', 'return register_widget("Xyz_Insert_Php_Widget");'));
139
  ?>
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
  /**
5
+ * XYZScripts Insert PHP Snippet Widget Class
6
+ */
 
7
  ////*****************************Sidebar Widget**********************************////
 
8
  class Xyz_Insert_Php_Widget extends WP_Widget {
 
 
9
  /** constructor -- name this the same as the class above */
10
  function __construct() {
11
  parent::__construct(false, $name = 'Insert PHP Snippet');
12
  }
 
13
  /** @see WP_Widget::widget -- do not rename this */
14
+ function widget($args, $instance){
15
  extract( $args );
16
  global $wpdb;
17
+ $title = apply_filters('widget_title', $instance['title']);
18
+ $xyz_ips_id = $instance['message'];
19
+ $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ips_short_code WHERE id=%d",$xyz_ips_id ));
 
 
20
  $entry = $entries[0];
 
21
  echo $before_widget;
22
  if ( $title )
23
+ echo $before_title . $title . $after_title;
24
+ $content_to_eval=$entry->content;
25
+ /***** to handle old codes : start *****/
26
+ if(get_option('xyz_ips_auto_insert')==1){
27
+ $xyz_ips_content_start='<?php';
28
+ $new_line="\r\n";
29
+ $xyz_ips_content_end='?>';
30
+ if (stripos($content_to_eval, '<?php') !== false)
31
+ $tag_start_position=stripos($content_to_eval,'<?php');
32
+ else
33
+ $tag_start_position="-1";
34
+ if (stripos($content_to_eval, '?>') !== false)
35
+ $tag_end_position=stripos($content_to_eval,'?>');
36
+ else
37
+ $tag_end_position="-1";
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
+ /***** to handle old codes : end *****/
59
+ else{
60
+ if(substr(trim($content_to_eval), 0,5)=='<?php')
61
+ $content_to_eval='?>'.$content_to_eval;
62
+ }
63
+
64
+ eval($content_to_eval);
65
  echo $after_widget;
 
66
  }
 
67
  /** @see WP_Widget::update -- do not rename this */
68
  function update($new_instance, $old_instance) {
69
+ $instance = $old_instance;
70
+ $instance['title'] = strip_tags($new_instance['title']);
71
+ $instance['message'] = strip_tags($new_instance['message']);
72
  return $instance;
73
  }
 
74
  /** @see WP_Widget::form -- do not rename this */
75
  function form($instance) {
76
+ global $wpdb;
77
+ $entries = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status=%d ORDER BY id DESC",1 ));
78
+ if(isset($instance['title'])){
79
+ $title = esc_attr($instance['title']);
80
+ }else{
81
+ $title = '';
82
+ }
83
+ if(isset($instance['message'])){
84
+ $message = esc_attr($instance['message']);
85
+ }else{
86
+ $message = '';
87
+ }
88
+ ?>
89
+ <p>
90
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
91
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
92
+ </p>
93
+ <p>
94
+ <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Choose Snippet :'); ?></label>
95
+ <select name="<?php echo $this->get_field_name('message'); ?>">
96
+ <?php
97
+ if( count($entries)>0 ) {
98
+ $count=1;
99
+ $class = '';
100
+ foreach( $entries as $entry ) {
101
  ?>
102
+ <option value="<?php echo $entry->id;?>" <?php if($message==$entry->id)echo "selected"; ?>><?php echo $entry->title;?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  <?php
104
+ }
105
+ }
106
+ ?>
107
+ </select>
108
+ </p>
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
  ?>
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
  ?>