Version Description
- Snippet selection support in classic editor block of Gutenberg
- Support for Search Snippet by name
- Navigation Improvements
Download this release
Release Info
Developer | f1logic |
Plugin | Insert PHP Code Snippet |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.6 to 1.3
- add_shortcode_tynimce.php +29 -3
- admin/about.php +8 -1
- admin/snippet-add.php +12 -3
- admin/snippet-edit.php +10 -3
- admin/snippets.php +63 -31
- editor_plugin.js.php +61 -20
- insert-php-code-snippet.php +2 -2
- readme.txt +7 -2
add_shortcode_tynimce.php
CHANGED
@@ -1,8 +1,34 @@
|
|
1 |
<?php
|
2 |
if ( ! defined( 'ABSPATH' ) )
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
class XYZ_Insert_Php_TinyMCESelector{
|
8 |
var $buttonName = 'xyz_ips_snippet_selecter';
|
@@ -38,6 +64,6 @@ endif;
|
|
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 |
+
add_action( 'admin_init', 'xyz_ips_tinymce_button' );
|
6 |
+
|
7 |
+
function xyz_ips_tinymce_button() {
|
8 |
+
if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
|
9 |
+
|
10 |
+
if ( get_user_option('rich_editing') == 'true') {
|
11 |
+
|
12 |
+
add_filter( 'mce_buttons', 'xyz_ips_register_tinymce_button' );
|
13 |
+
add_filter( 'mce_external_plugins', 'xyz_ips_add_tinymce_button' );
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
function xyz_ips_register_tinymce_button( $buttons ) {
|
19 |
+
|
20 |
+
$buttonName = 'xyz_ips_snippet_selecter';
|
21 |
+
|
22 |
+
array_push( $buttons, $buttonName);
|
23 |
+
return $buttons;
|
24 |
+
}
|
25 |
+
|
26 |
+
function xyz_ips_add_tinymce_button( $plugin_array ) {
|
27 |
+
$plugin_array['xyz_ips_buttons'] = get_site_url() . '/index.php?wp_ips=editor_plugin_js';
|
28 |
+
return $plugin_array;
|
29 |
+
}
|
30 |
+
|
31 |
+
/*if(!class_exists('XYZ_Insert_Php_TinyMCESelector')):
|
32 |
|
33 |
class XYZ_Insert_Php_TinyMCESelector{
|
34 |
var $buttonName = 'xyz_ips_snippet_selecter';
|
64 |
if(!isset($shortcodesXYZEP)){
|
65 |
$shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();
|
66 |
add_action('admin_head', array($shortcodesXYZEP, 'addSelector'));
|
67 |
+
}*/
|
68 |
|
69 |
?>
|
admin/about.php
CHANGED
@@ -151,7 +151,7 @@ Integrate PHP code seamlessly to your wordpress. This plugin lets you generate a
|
|
151 |
</tr>
|
152 |
<!-- Snippet Targeting -->
|
153 |
<tr>
|
154 |
-
<td rowspan="
|
155 |
<td><b>Geographic Targeting</b></td>
|
156 |
<td><img src="<?php echo plugins_url('images/cross.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
157 |
</td>
|
@@ -171,6 +171,13 @@ Integrate PHP code seamlessly to your wordpress. This plugin lets you generate a
|
|
171 |
</td>
|
172 |
<td><img src="<?php echo plugins_url('images/tick.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
173 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
</tr>
|
175 |
<!-- Integration -->
|
176 |
|
151 |
</tr>
|
152 |
<!-- Snippet Targeting -->
|
153 |
<tr>
|
154 |
+
<td rowspan="4"><h4>Snippet Targeting</h4></td>
|
155 |
<td><b>Geographic Targeting</b></td>
|
156 |
<td><img src="<?php echo plugins_url('images/cross.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
157 |
</td>
|
171 |
</td>
|
172 |
<td><img src="<?php echo plugins_url('images/tick.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
173 |
</td>
|
174 |
+
</tr>
|
175 |
+
<tr>
|
176 |
+
<td><b>Date & Time Targeting</b></td>
|
177 |
+
<td><img src="<?php echo plugins_url('images/cross.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
178 |
+
</td>
|
179 |
+
<td><img src="<?php echo plugins_url('images/tick.png',XYZ_INSERT_PHP_PLUGIN_FILE);?>">
|
180 |
+
</td>
|
181 |
</tr>
|
182 |
<!-- Integration -->
|
183 |
|
admin/snippet-add.php
CHANGED
@@ -3,6 +3,7 @@ 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'])){
|
@@ -10,7 +11,8 @@ if(isset($_POST) && isset($_POST['addSubmit'])){
|
|
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']);
|
@@ -93,7 +95,10 @@ if(isset($_POST) && isset($_POST['addSubmit'])){
|
|
93 |
</legend>
|
94 |
<form name="frmmainForm" id="frmmainForm" method="post">
|
95 |
<?php wp_nonce_field('ips-padd_'); ?>
|
|
|
|
|
96 |
<div>
|
|
|
97 |
<table
|
98 |
style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
|
99 |
<tr>
|
@@ -150,8 +155,12 @@ if(isset($_POST) && isset($_POST['addSubmit'])){
|
|
150 |
<tr>
|
151 |
<td>
|
152 |
</td>
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
155 |
<td>
|
156 |
<input class="button-primary" style="cursor: pointer;"
|
157 |
type="submit" name="addSubmit" value="Create">
|
3 |
exit;
|
4 |
|
5 |
global $wpdb;
|
6 |
+
$goback=1;
|
7 |
$_POST = stripslashes_deep($_POST);
|
8 |
$_POST = xyz_trim_deep($_POST);
|
9 |
if(isset($_POST) && isset($_POST['addSubmit'])){
|
11 |
wp_nonce_ays( 'ips-padd_' );
|
12 |
exit;
|
13 |
}
|
14 |
+
$goback=intval($_POST['goback']);
|
15 |
+
$goback++;
|
16 |
$temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
|
17 |
$temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
|
18 |
$xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
|
95 |
</legend>
|
96 |
<form name="frmmainForm" id="frmmainForm" method="post">
|
97 |
<?php wp_nonce_field('ips-padd_'); ?>
|
98 |
+
|
99 |
+
|
100 |
<div>
|
101 |
+
<input type="hidden" name="goback" value=<?php echo $goback;?>>
|
102 |
<table
|
103 |
style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
|
104 |
<tr>
|
155 |
<tr>
|
156 |
<td>
|
157 |
</td>
|
158 |
+
<td>
|
159 |
+
|
160 |
+
|
161 |
+
<input class="button-primary" style="cursor: pointer;"
|
162 |
+
type="button" name="back" value="back" onclick=" window.history.go(-<?php echo $goback;?>);" >
|
163 |
+
</td>
|
164 |
<td>
|
165 |
<input class="button-primary" style="cursor: pointer;"
|
166 |
type="submit" name="addSubmit" value="Create">
|
admin/snippet-edit.php
CHANGED
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
3 |
exit;
|
4 |
|
5 |
global $wpdb;
|
6 |
-
|
7 |
$xyz_ips_snippetId = intval($_GET['snippetId']);
|
8 |
$xyz_ips_message='';
|
9 |
if(isset($_GET['xyz_ips_msg'])){
|
@@ -17,13 +17,16 @@ if($xyz_ips_message == 1){
|
|
17 |
</div>
|
18 |
<?php
|
19 |
}
|
|
|
|
|
20 |
if(isset($_POST) && isset($_POST['updateSubmit'])){
|
21 |
|
22 |
if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-pedit_'.$xyz_ips_snippetId )) {
|
23 |
wp_nonce_ays( 'ips-pedit_'.$xyz_ips_snippetId );
|
24 |
exit;
|
25 |
}
|
26 |
-
|
|
|
27 |
$_POST = stripslashes_deep($_POST);
|
28 |
$_POST = xyz_trim_deep($_POST);
|
29 |
$xyz_ips_snippetId = intval($_GET['snippetId']);
|
@@ -74,7 +77,7 @@ if(get_option('xyz_ips_auto_insert')==1){
|
|
74 |
if($snippet_count == 0){
|
75 |
$xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
|
76 |
$wpdb->update($wpdb->prefix.'xyz_ips_short_code', array('title'=>$xyz_ips_title,'content'=>$xyz_ips_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ips_snippetId));
|
77 |
-
header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$xyz_ips_snippetId.'&xyz_ips_msg=1'));
|
78 |
}
|
79 |
else{
|
80 |
?>
|
@@ -121,6 +124,8 @@ $snippetDetails = $snippetDetails[0];
|
|
121 |
value="
|
122 |
<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
|
123 |
<div>
|
|
|
|
|
124 |
<table
|
125 |
style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
|
126 |
<tr>
|
@@ -176,6 +181,8 @@ $snippetDetails = $snippetDetails[0];
|
|
176 |
<td>
|
177 |
</td>
|
178 |
<td>
|
|
|
|
|
179 |
</td>
|
180 |
<td>
|
181 |
<input class="button-primary" style="cursor: pointer;"
|
3 |
exit;
|
4 |
|
5 |
global $wpdb;
|
6 |
+
$goback=1;
|
7 |
$xyz_ips_snippetId = intval($_GET['snippetId']);
|
8 |
$xyz_ips_message='';
|
9 |
if(isset($_GET['xyz_ips_msg'])){
|
17 |
</div>
|
18 |
<?php
|
19 |
}
|
20 |
+
if($_GET['goback'])
|
21 |
+
$goback= intval($_GET['goback']);
|
22 |
if(isset($_POST) && isset($_POST['updateSubmit'])){
|
23 |
|
24 |
if (! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ips-pedit_'.$xyz_ips_snippetId )) {
|
25 |
wp_nonce_ays( 'ips-pedit_'.$xyz_ips_snippetId );
|
26 |
exit;
|
27 |
}
|
28 |
+
$goback=intval($_POST['goback']);
|
29 |
+
$goback++;
|
30 |
$_POST = stripslashes_deep($_POST);
|
31 |
$_POST = xyz_trim_deep($_POST);
|
32 |
$xyz_ips_snippetId = intval($_GET['snippetId']);
|
77 |
if($snippet_count == 0){
|
78 |
$xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
|
79 |
$wpdb->update($wpdb->prefix.'xyz_ips_short_code', array('title'=>$xyz_ips_title,'content'=>$xyz_ips_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ips_snippetId));
|
80 |
+
header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$xyz_ips_snippetId.'&xyz_ips_msg=1'.'&goback='.$goback));
|
81 |
}
|
82 |
else{
|
83 |
?>
|
124 |
value="
|
125 |
<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
|
126 |
<div>
|
127 |
+
<input type="hidden" name="goback" value= <?php echo $goback;?>>
|
128 |
+
|
129 |
<table
|
130 |
style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
|
131 |
<tr>
|
181 |
<td>
|
182 |
</td>
|
183 |
<td>
|
184 |
+
<input class="button-primary" style="cursor: pointer;"
|
185 |
+
type="button" name="back" onclick=" window.history.go(-<?php echo $goback;?>);" value="back" >
|
186 |
</td>
|
187 |
<td>
|
188 |
<input class="button-primary" style="cursor: pointer;"
|
admin/snippets.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) )
|
3 |
exit;
|
4 |
|
5 |
global $wpdb;
|
@@ -10,10 +10,20 @@ if(isset($_GET['xyz_ips_msg'])){
|
|
10 |
}
|
11 |
if($_POST)
|
12 |
{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
if (isset($_POST['apply_ips_bulk_actions'])){
|
18 |
if (isset($_POST['ips_bulk_actions_snippet'])){
|
19 |
$ips_bulk_actions_snippet=$_POST['ips_bulk_actions_snippet'];
|
@@ -54,9 +64,9 @@ if($_POST)
|
|
54 |
exit();
|
55 |
}
|
56 |
}
|
57 |
-
|
58 |
}
|
59 |
-
|
60 |
}
|
61 |
if($xyz_ips_message == 1){
|
62 |
|
@@ -115,7 +125,7 @@ if($xyz_ips_message == 7)
|
|
115 |
Please select an action to apply.
|
116 |
<span id="xyz_system_notice_area_dismiss">Dismiss</span>
|
117 |
</div>
|
118 |
-
<?php
|
119 |
}
|
120 |
if($xyz_ips_message == 8)
|
121 |
{
|
@@ -135,19 +145,20 @@ if($xyz_ips_message == 8)
|
|
135 |
<fieldset
|
136 |
style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
|
137 |
<legend><h3>PHP Code Snippets</h3></legend>
|
138 |
-
<?php
|
139 |
global $wpdb;
|
140 |
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
|
141 |
-
$limit = get_option('xyz_ips_limit');
|
142 |
$offset = ( $pagenum - 1 ) * $limit;
|
143 |
|
144 |
|
145 |
$field=get_option('xyz_ips_sort_field_name');
|
146 |
$order=get_option('xyz_ips_sort_order');
|
147 |
-
|
148 |
-
|
|
|
|
|
149 |
|
150 |
-
|
151 |
?>
|
152 |
<input id="xyz_ips_submit_ips"
|
153 |
style="cursor: pointer; margin-bottom:10px; margin-left:8px;" type="button"
|
@@ -162,7 +173,28 @@ if($xyz_ips_message == 8)
|
|
162 |
<option value="2">Delete</option>
|
163 |
</select>
|
164 |
<input type="submit" title="Apply" name="apply_ips_bulk_actions" value="Apply" style="color:#21759B;cursor:pointer;padding: 5px;background:linear-gradient(to top, #ECECEC, #F9F9F9) repeat scroll 0 0 #F1F1F1;border: 2px solid #DFDFDF;">
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
<table class="widefat" style="width: 99%; margin: 0 auto; border-bottom:none;">
|
167 |
<thead>
|
168 |
<tr>
|
@@ -174,7 +206,7 @@ if($xyz_ips_message == 8)
|
|
174 |
</tr>
|
175 |
</thead>
|
176 |
<tbody>
|
177 |
-
<?php
|
178 |
if( count($entries)>0 ) {
|
179 |
$count=1;
|
180 |
$class = '';
|
@@ -186,25 +218,25 @@ if($xyz_ips_message == 8)
|
|
186 |
<td style="vertical-align: middle !important;padding-left: 18px;">
|
187 |
<input type="checkbox" class="chk" value="<?php echo $snippetId; ?>" name="xyz_ips_snippet_ids[]" id="xyz_ips_snippet_ids" />
|
188 |
</td>
|
189 |
-
<td id="xyz_ips_vAlign"><?php
|
190 |
echo esc_html($entry->title);
|
191 |
?></td>
|
192 |
-
<td id="xyz_ips_vAlign"><?php
|
193 |
if($entry->status == 2){echo 'NA';}
|
194 |
else
|
195 |
echo '[xyz-ips snippet="'.esc_html($entry->title).'"]';
|
196 |
?></td>
|
197 |
<td id="xyz_ips_vAlign">
|
198 |
-
<?php
|
199 |
if($entry->status == 2){
|
200 |
-
echo "Inactive";
|
201 |
}elseif ($entry->status == 1){
|
202 |
-
echo "Active";
|
203 |
}
|
204 |
-
|
205 |
?>
|
206 |
</td>
|
207 |
-
<?php
|
208 |
if($entry->status == 2){
|
209 |
$stat1 = admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=1&pageno='.$pagenum);
|
210 |
?>
|
@@ -214,7 +246,7 @@ if($xyz_ips_message == 8)
|
|
214 |
src="<?php echo plugins_url('images/activate.png',XYZ_INSERT_PHP_PLUGIN_FILE)?>">
|
215 |
</a>
|
216 |
</td>
|
217 |
-
<?php
|
218 |
}elseif ($entry->status == 1){
|
219 |
$stat2 = admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=2&pageno='.$pagenum);
|
220 |
?>
|
@@ -223,12 +255,12 @@ if($xyz_ips_message == 8)
|
|
223 |
id="xyz_ips_img" title="Deactivate"
|
224 |
src="<?php echo plugins_url('images/pause.png',XYZ_INSERT_PHP_PLUGIN_FILE)?>">
|
225 |
</a>
|
226 |
-
</td>
|
227 |
-
<?php
|
228 |
}
|
229 |
-
|
230 |
?>
|
231 |
-
|
232 |
<td style="text-align: center;"><a
|
233 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$snippetId.'&pageno='.$pagenum); ?>'><img
|
234 |
id="xyz_ips_img" title="Edit Snippet"
|
@@ -254,12 +286,12 @@ if($xyz_ips_message == 8)
|
|
254 |
<?php } ?>
|
255 |
</tbody>
|
256 |
</table>
|
257 |
-
|
258 |
<input id="xyz_ips_submit_ips"
|
259 |
style="cursor: pointer; margin-top:10px;margin-left:8px;" type="button"
|
260 |
name="textFieldButton2" value="Add New PHP Code Snippet"
|
261 |
onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'>
|
262 |
-
|
263 |
<?php
|
264 |
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM ".$wpdb->prefix."xyz_ips_short_code" );
|
265 |
$num_of_pages = ceil( $total / $limit );
|
@@ -290,6 +322,6 @@ if($xyz_ips_message == 8)
|
|
290 |
jQuery(document).ready(function(){
|
291 |
jQuery("#chkAllSnippets").click(function(){
|
292 |
jQuery(".chk").prop("checked",jQuery("#chkAllSnippets").prop("checked"));
|
293 |
-
});
|
294 |
});
|
295 |
</script>
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) )
|
3 |
exit;
|
4 |
|
5 |
global $wpdb;
|
10 |
}
|
11 |
if($_POST)
|
12 |
{
|
13 |
+
if(isset($_POST['search']))
|
14 |
+
{
|
15 |
+
if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'snipp-manage_') ){
|
16 |
+
wp_nonce_ays( 'snipp-manage_' );
|
17 |
+
exit;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
if(isset($_POST['textFieldButton2']))
|
21 |
+
{
|
22 |
+
if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'bulk_actions_ips') ){
|
23 |
+
wp_nonce_ays( 'bulk_actions_ips' );
|
24 |
+
exit;
|
25 |
+
}
|
26 |
+
}
|
27 |
if (isset($_POST['apply_ips_bulk_actions'])){
|
28 |
if (isset($_POST['ips_bulk_actions_snippet'])){
|
29 |
$ips_bulk_actions_snippet=$_POST['ips_bulk_actions_snippet'];
|
64 |
exit();
|
65 |
}
|
66 |
}
|
67 |
+
|
68 |
}
|
69 |
+
|
70 |
}
|
71 |
if($xyz_ips_message == 1){
|
72 |
|
125 |
Please select an action to apply.
|
126 |
<span id="xyz_system_notice_area_dismiss">Dismiss</span>
|
127 |
</div>
|
128 |
+
<?php
|
129 |
}
|
130 |
if($xyz_ips_message == 8)
|
131 |
{
|
145 |
<fieldset
|
146 |
style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
|
147 |
<legend><h3>PHP Code Snippets</h3></legend>
|
148 |
+
<?php
|
149 |
global $wpdb;
|
150 |
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
|
151 |
+
$limit = get_option('xyz_ips_limit');
|
152 |
$offset = ( $pagenum - 1 ) * $limit;
|
153 |
|
154 |
|
155 |
$field=get_option('xyz_ips_sort_field_name');
|
156 |
$order=get_option('xyz_ips_sort_order');
|
157 |
+
$search_name=sanitize_text_field($_POST['snippet_name']);
|
158 |
+
$search_name_db=esc_sql($search_name);
|
159 |
+
$entries = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE title like '%".$search_name_db."%'"." ORDER BY $field $order LIMIT $offset,$limit" );
|
160 |
+
|
161 |
|
|
|
162 |
?>
|
163 |
<input id="xyz_ips_submit_ips"
|
164 |
style="cursor: pointer; margin-bottom:10px; margin-left:8px;" type="button"
|
173 |
<option value="2">Delete</option>
|
174 |
</select>
|
175 |
<input type="submit" title="Apply" name="apply_ips_bulk_actions" value="Apply" style="color:#21759B;cursor:pointer;padding: 5px;background:linear-gradient(to top, #ECECEC, #F9F9F9) repeat scroll 0 0 #F1F1F1;border: 2px solid #DFDFDF;">
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
<form name="manage_snippets" action="" method="post">
|
180 |
+
<?php wp_nonce_field('snipp-manage_');?>
|
181 |
+
<div class="xyz_ips_search_div" style="float:right;">
|
182 |
+
<table class="xyz_ips_search_div_table" style="width:100%;">
|
183 |
+
<tr>
|
184 |
+
|
185 |
+
|
186 |
+
<input type="text" name="snippet_name" value= "<?php if(isset($search_name)){echo esc_attr($search_name);}?>" placeholder="Search" >
|
187 |
+
<input type="submit" name="search" value="Go" />
|
188 |
+
|
189 |
+
</tr>
|
190 |
+
</table>
|
191 |
+
</div>
|
192 |
+
</form>
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
<table class="widefat" style="width: 99%; margin: 0 auto; border-bottom:none;">
|
199 |
<thead>
|
200 |
<tr>
|
206 |
</tr>
|
207 |
</thead>
|
208 |
<tbody>
|
209 |
+
<?php
|
210 |
if( count($entries)>0 ) {
|
211 |
$count=1;
|
212 |
$class = '';
|
218 |
<td style="vertical-align: middle !important;padding-left: 18px;">
|
219 |
<input type="checkbox" class="chk" value="<?php echo $snippetId; ?>" name="xyz_ips_snippet_ids[]" id="xyz_ips_snippet_ids" />
|
220 |
</td>
|
221 |
+
<td id="xyz_ips_vAlign"><?php
|
222 |
echo esc_html($entry->title);
|
223 |
?></td>
|
224 |
+
<td id="xyz_ips_vAlign"><?php
|
225 |
if($entry->status == 2){echo 'NA';}
|
226 |
else
|
227 |
echo '[xyz-ips snippet="'.esc_html($entry->title).'"]';
|
228 |
?></td>
|
229 |
<td id="xyz_ips_vAlign">
|
230 |
+
<?php
|
231 |
if($entry->status == 2){
|
232 |
+
echo "Inactive";
|
233 |
}elseif ($entry->status == 1){
|
234 |
+
echo "Active";
|
235 |
}
|
236 |
+
|
237 |
?>
|
238 |
</td>
|
239 |
+
<?php
|
240 |
if($entry->status == 2){
|
241 |
$stat1 = admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=1&pageno='.$pagenum);
|
242 |
?>
|
246 |
src="<?php echo plugins_url('images/activate.png',XYZ_INSERT_PHP_PLUGIN_FILE)?>">
|
247 |
</a>
|
248 |
</td>
|
249 |
+
<?php
|
250 |
}elseif ($entry->status == 1){
|
251 |
$stat2 = admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=2&pageno='.$pagenum);
|
252 |
?>
|
255 |
id="xyz_ips_img" title="Deactivate"
|
256 |
src="<?php echo plugins_url('images/pause.png',XYZ_INSERT_PHP_PLUGIN_FILE)?>">
|
257 |
</a>
|
258 |
+
</td>
|
259 |
+
<?php
|
260 |
}
|
261 |
+
|
262 |
?>
|
263 |
+
|
264 |
<td style="text-align: center;"><a
|
265 |
href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$snippetId.'&pageno='.$pagenum); ?>'><img
|
266 |
id="xyz_ips_img" title="Edit Snippet"
|
286 |
<?php } ?>
|
287 |
</tbody>
|
288 |
</table>
|
289 |
+
|
290 |
<input id="xyz_ips_submit_ips"
|
291 |
style="cursor: pointer; margin-top:10px;margin-left:8px;" type="button"
|
292 |
name="textFieldButton2" value="Add New PHP Code Snippet"
|
293 |
onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'>
|
294 |
+
|
295 |
<?php
|
296 |
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM ".$wpdb->prefix."xyz_ips_short_code" );
|
297 |
$num_of_pages = ceil( $total / $limit );
|
322 |
jQuery(document).ready(function(){
|
323 |
jQuery("#chkAllSnippets").click(function(){
|
324 |
jQuery(".chk").prop("checked",jQuery("#chkAllSnippets").prop("checked"));
|
325 |
+
});
|
326 |
});
|
327 |
</script>
|
editor_plugin.js.php
CHANGED
@@ -6,11 +6,11 @@ header( 'Content-Type: text/javascript' );
|
|
6 |
if ( ! is_user_logged_in() )
|
7 |
die('You must be logged in to access this script.');
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
|
15 |
$xyz_snippets_arr=$wpdb->get_results($wpdb->prepare( "SELECT id,title FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status=%d ORDER BY id DESC",1),ARRAY_A );
|
16 |
// print_r($xyz_snippets_arr);
|
@@ -19,11 +19,52 @@ die;
|
|
19 |
|
20 |
if(floatval(get_bloginfo('version'))>=3.9)
|
21 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
?>
|
23 |
(function() {
|
24 |
|
25 |
-
tinymce.PluginManager.add('<?php echo $
|
26 |
-
editor.addButton( '<?php echo $
|
27 |
title: 'Insert PHP Code Snippet',
|
28 |
type: 'menubutton',
|
29 |
icon: 'icon xyz-ips-own-icon',
|
@@ -42,7 +83,7 @@ if(floatval(get_bloginfo('version'))>=3.9)
|
|
42 |
});
|
43 |
|
44 |
})();
|
45 |
-
<?php } else {
|
46 |
|
47 |
$xyz_snippets = array(
|
48 |
'title' =>'Insert PHP Code Snippet',
|
@@ -51,13 +92,13 @@ if(floatval(get_bloginfo('version'))>=3.9)
|
|
51 |
);
|
52 |
?>
|
53 |
|
54 |
-
var tinymce_<?php echo $
|
55 |
|
56 |
|
57 |
(function() {
|
58 |
//******* Load plugin specific language pack
|
59 |
|
60 |
-
tinymce.create('tinymce.plugins.<?php echo $
|
61 |
/**
|
62 |
* Initializes the plugin, this will be executed after the plugin has been created.
|
63 |
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
@@ -68,9 +109,9 @@ var tinymce_<?php echo $shortcodesXYZEP->buttonName; ?> =<?php echo json_encode(
|
|
68 |
*/
|
69 |
init : function(ed, url) {
|
70 |
|
71 |
-
tinymce_<?php echo $
|
72 |
if(this.v && this.v != ''){
|
73 |
-
tinymce.execCommand('mceInsertContent', false, '[xyz-ips snippet="'+tinymce_<?php echo $
|
74 |
}
|
75 |
};
|
76 |
|
@@ -87,22 +128,22 @@ var tinymce_<?php echo $shortcodesXYZEP->buttonName; ?> =<?php echo json_encode(
|
|
87 |
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
88 |
*/
|
89 |
createControl : function(n, cm) {
|
90 |
-
if(n=='<?php echo $
|
91 |
-
var c = cm.createSplitButton('<?php echo $
|
92 |
-
title : tinymce_<?php echo $
|
93 |
-
image : tinymce_<?php echo $
|
94 |
-
onclick : tinymce_<?php echo $
|
95 |
});
|
96 |
|
97 |
// Add some values to the list box
|
98 |
|
99 |
|
100 |
c.onRenderMenu.add(function(c, m){
|
101 |
-
for (var id in tinymce_<?php echo $
|
102 |
m.add({
|
103 |
v : id,
|
104 |
-
title : tinymce_<?php echo $
|
105 |
-
onclick : tinymce_<?php echo $
|
106 |
});
|
107 |
}
|
108 |
});
|
@@ -119,7 +160,7 @@ var tinymce_<?php echo $shortcodesXYZEP->buttonName; ?> =<?php echo json_encode(
|
|
119 |
});
|
120 |
|
121 |
// Register plugin
|
122 |
-
tinymce.PluginManager.add('<?php echo $
|
123 |
})();
|
124 |
|
125 |
<?php } ?>
|
6 |
if ( ! is_user_logged_in() )
|
7 |
die('You must be logged in to access this script.');
|
8 |
|
9 |
+
/*if(!isset($shortcodesXYZEP))
|
10 |
+
$shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();*/
|
11 |
|
12 |
+
global $wpdb;
|
13 |
+
$buttonName = 'xyz_ips_snippet_selecter';
|
14 |
|
15 |
$xyz_snippets_arr=$wpdb->get_results($wpdb->prepare( "SELECT id,title FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status=%d ORDER BY id DESC",1),ARRAY_A );
|
16 |
// print_r($xyz_snippets_arr);
|
19 |
|
20 |
if(floatval(get_bloginfo('version'))>=3.9)
|
21 |
{
|
22 |
+
?>
|
23 |
+
(function() {
|
24 |
+
/* Register the buttons */
|
25 |
+
tinymce.create('tinymce.plugins.xyz_ips_snippet', {
|
26 |
+
init : function(ed, url) {
|
27 |
+
/**
|
28 |
+
* Inserts shortcode content
|
29 |
+
*/
|
30 |
+
ed.addButton( '<?php echo $buttonName;?>', {
|
31 |
+
title: 'Insert PHP Code Snippet',
|
32 |
+
type: 'menubutton',
|
33 |
+
icon: 'icon xyz-ips-own-icon',
|
34 |
+
menu: [
|
35 |
+
|
36 |
+
<?php foreach ($xyz_snippets_arr as $key=>$val) { ?>
|
37 |
+
{
|
38 |
+
text: '<?php echo addslashes($val['title']); ?>',
|
39 |
+
value: '[xyz-ips snippet="<?php echo addslashes($val['title']); ?>"]',
|
40 |
+
onclick: function() {
|
41 |
+
ed.selection.setContent(this.value());
|
42 |
+
}
|
43 |
+
},
|
44 |
+
<?php } ?>
|
45 |
+
|
46 |
+
]
|
47 |
+
|
48 |
+
});
|
49 |
+
|
50 |
+
|
51 |
+
},
|
52 |
+
createControl : function(n, cm) {
|
53 |
+
return null;
|
54 |
+
},
|
55 |
+
});
|
56 |
+
/* Start the buttons */
|
57 |
+
tinymce.PluginManager.add( 'xyz_ips_buttons', tinymce.plugins.xyz_ips_snippet );
|
58 |
+
})();
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
/*else if(floatval(get_bloginfo('version'))>=3.9)
|
62 |
+
{
|
63 |
?>
|
64 |
(function() {
|
65 |
|
66 |
+
tinymce.PluginManager.add('<?php echo $buttonName; ?>', function( editor, url ) {
|
67 |
+
editor.addButton( '<?php echo $buttonName; ?>', {
|
68 |
title: 'Insert PHP Code Snippet',
|
69 |
type: 'menubutton',
|
70 |
icon: 'icon xyz-ips-own-icon',
|
83 |
});
|
84 |
|
85 |
})();
|
86 |
+
<?php }*/ else {
|
87 |
|
88 |
$xyz_snippets = array(
|
89 |
'title' =>'Insert PHP Code Snippet',
|
92 |
);
|
93 |
?>
|
94 |
|
95 |
+
var tinymce_<?php echo $buttonName; ?> =<?php echo json_encode($xyz_snippets) ?>;
|
96 |
|
97 |
|
98 |
(function() {
|
99 |
//******* Load plugin specific language pack
|
100 |
|
101 |
+
tinymce.create('tinymce.plugins.<?php echo $buttonName; ?>', {
|
102 |
/**
|
103 |
* Initializes the plugin, this will be executed after the plugin has been created.
|
104 |
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
109 |
*/
|
110 |
init : function(ed, url) {
|
111 |
|
112 |
+
tinymce_<?php echo $buttonName; ?>.insert = function(){
|
113 |
if(this.v && this.v != ''){
|
114 |
+
tinymce.execCommand('mceInsertContent', false, '[xyz-ips snippet="'+tinymce_<?php echo $buttonName; ?>.xyz_ips_snippets[this.v]['title']+'"]');
|
115 |
}
|
116 |
};
|
117 |
|
128 |
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
129 |
*/
|
130 |
createControl : function(n, cm) {
|
131 |
+
if(n=='<?php echo $buttonName; ?>'){
|
132 |
+
var c = cm.createSplitButton('<?php echo $buttonName; ?>', {
|
133 |
+
title : tinymce_<?php echo $buttonName; ?>.title,
|
134 |
+
image : tinymce_<?php echo $buttonName; ?>.url,
|
135 |
+
onclick : tinymce_<?php echo $buttonName; ?>.insert
|
136 |
});
|
137 |
|
138 |
// Add some values to the list box
|
139 |
|
140 |
|
141 |
c.onRenderMenu.add(function(c, m){
|
142 |
+
for (var id in tinymce_<?php echo $buttonName; ?>.xyz_ips_snippets){
|
143 |
m.add({
|
144 |
v : id,
|
145 |
+
title : tinymce_<?php echo $buttonName; ?>.xyz_ips_snippets[id]['title'],
|
146 |
+
onclick : tinymce_<?php echo $buttonName; ?>.insert
|
147 |
});
|
148 |
}
|
149 |
});
|
160 |
});
|
161 |
|
162 |
// Register plugin
|
163 |
+
tinymce.PluginManager.add('<?php echo $buttonName; ?>', tinymce.plugins.<?php echo $buttonName; ?>);
|
164 |
})();
|
165 |
|
166 |
<?php } ?>
|
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.
|
7 |
Author: xyzscripts.com
|
8 |
Author URI: http://xyzscripts.com/
|
9 |
Text Domain: insert-php-code-snippet
|
@@ -68,4 +68,4 @@ function xyz_ips_credit() {
|
|
68 |
}
|
69 |
|
70 |
|
71 |
-
?>
|
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.3
|
7 |
Author: xyzscripts.com
|
8 |
Author URI: http://xyzscripts.com/
|
9 |
Text Domain: insert-php-code-snippet
|
68 |
}
|
69 |
|
70 |
|
71 |
+
?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ 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:
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Add PHP code to your pages and posts easily using shortcodes.
|
@@ -66,6 +66,11 @@ More questions ? [Drop a mail](http://xyzscripts.com/members/support/ "XYZScript
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
= 1.2.6 =
|
70 |
* Support for Bulk Actions(activate,deactivate,delete)
|
71 |
|
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: 5.2.1
|
7 |
+
Stable tag: 1.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.3 =
|
70 |
+
* Snippet selection support in classic editor block of Gutenberg
|
71 |
+
* Support for Search Snippet by name
|
72 |
+
* Navigation Improvements
|
73 |
+
|
74 |
= 1.2.6 =
|
75 |
* Support for Bulk Actions(activate,deactivate,delete)
|
76 |
|