Insert PHP Code Snippet - Version 1.0

Version Description

  • First official launch.

=

Download this release

Release Info

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

Version 1.0

add_shortcode_tynimce.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!class_exists('XYZ_Insert_Php_TinyMCESelector')):
4
+
5
+ class XYZ_Insert_Php_TinyMCESelector{
6
+ var $buttonName = 'xyz_ips_snippet_selecter';
7
+ function addSelector(){
8
+ // Don't bother doing this stuff if the current user lacks permissions
9
+ if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
10
+ return;
11
+
12
+ // Add only in Rich Editor mode
13
+ if ( get_user_option('rich_editing') == 'true') {
14
+ add_filter('mce_external_plugins', array($this, 'registerTmcePlugin'));
15
+ //you can use the filters mce_buttons_2, mce_buttons_3 and mce_buttons_4
16
+ //to add your button to other toolbars of your tinymce
17
+ add_filter('mce_buttons', array($this, 'registerButton'));
18
+ }
19
+ }
20
+
21
+ function registerButton($buttons){
22
+ array_push($buttons, "separator", $this->buttonName);
23
+ return $buttons;
24
+ }
25
+
26
+ function registerTmcePlugin($plugin_array){
27
+
28
+ $plugin_array[$this->buttonName] =get_site_url() . '/index.php?wp_ips=editor_plugin_js';
29
+
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
+
admin/about.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ </style>
3
+
4
+ <h1 style="visibility: visible;">Insert PHP Code Snippet (V <?php echo xyz_ips_plugin_get_version(); ?>)</h1>
5
+ Integrate PHP code seamlessly to your wordpress. This plugin lets you generate a shortcode corresponding to any random PHP code. The shortcodes can be used in your pages, posts and widgets. Insert PHP Snippet is developed and maintained by <a href="http://xyzscripts.com">xyzscripts</a>.
6
+
7
+
8
+ <br />
9
+ <h2>Features</h2>
10
+
11
+ <div>
12
+ <p></p>
13
+
14
+ <div style="float: left;">
15
+
16
+
17
+ <ul>
18
+ <li>Convert PHP Code snippets to shortcodes</li>
19
+ <li>Support for shortcodes in widgets</li>
20
+ <li>Dropdown menu in TinyMCE editor to pick snippets easily</li>
21
+ </ul>
22
+
23
+
24
+ </div>
25
+
26
+
27
+
28
+ </div>
29
+
30
+
31
+
32
+
33
+ <div style="clear: both;"></div>
34
+
35
+
admin/ajax-backlink.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action('wp_ajax_ajax_backlink', 'xyz_ips_ajax_backlink');
3
+ function xyz_ips_ajax_backlink() {
4
+
5
+ global $wpdb;
6
+
7
+ if($_POST){
8
+ update_option('xyz_credit_link','ips');
9
+
10
+ }
11
+ }
12
+
13
+
14
+ ?>
admin/footer.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="clear: both;"></div>
2
+
3
+
4
+ <p></p>
5
+
6
+ <div style="width: 100%">
7
+
8
+ <div class="xyz_feedback">
9
+
10
+
11
+ <a target="_blank" href="http://xyzscripts.com/support/" class="xyz_suggest">Suggestions</a> -
12
+ <a target="_blank" href="http://facebook.com/xyzscripts" class="xyz_fbook">Like us on facebook</a> -
13
+ <a target="_blank" href="http://twitter.com/xyzscripts" class="xyz_twitt">Follow us on twitter</a> -
14
+ <a target="_blank" href="https://plus.google.com/101215320403235276710/" class="xyz_gplus">+1 us on Google+</a>
15
+
16
+
17
+ </div>
18
+
19
+ <p></p>
20
+
21
+ <div class="xyz_subscribe">
22
+
23
+ <script language="javascript">
24
+ function check_email(emailString)
25
+ {
26
+ var mailPattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
27
+ var matchArray = emailString.match(mailPattern);
28
+ if (emailString.length == 0)
29
+ return false;
30
+
31
+ if (matchArray == null) {
32
+ return false;
33
+ }else{
34
+ return true;
35
+ }
36
+ }
37
+
38
+
39
+ function verify_lists(form)
40
+ {
41
+
42
+ var total=0;
43
+ var checkBox=form['chk[]'];
44
+
45
+ if(checkBox.length){
46
+
47
+ for(var i=0;i<checkBox.length;i++){
48
+ checkBox[i].checked?total++:null;
49
+ }
50
+ }else{
51
+
52
+ checkBox.checked?total++:null;
53
+
54
+ }
55
+ if(total>0){
56
+ return true;
57
+ }else{
58
+ return false;
59
+ }
60
+
61
+ }
62
+
63
+ function verify_fields()
64
+ {
65
+
66
+ if(check_email(document.email_subscription.email.value) == false){
67
+ alert("Please check whether the email is correct.");
68
+ document.email_subscription.email.select();
69
+ return false;
70
+ }else if(verify_lists(document.email_subscription)==false){
71
+ alert("Select atleast one list.");
72
+ }
73
+ else{
74
+ document.email_subscription.submit();
75
+ }
76
+
77
+ }
78
+ </script>
79
+ <?php global $current_user; get_currentuserinfo(); ?>
80
+ <form action="http://xyzscripts.com/newsletter/index.php?page=list/subscribe" method="post" name="email_subscription" id="email_subscription" >
81
+ <input type="hidden" name="fieldNameIds" value="1,">
82
+ <input type="hidden" name="redirActive" value="http://xyzscripts.com/subscription/pending/XYZWPIPSFRE">
83
+ <input type="hidden" name="redirPending" value="http://xyzscripts.com/subscription/active/XYZWPIPSFRE">
84
+ <input type="hidden" name="mode" value="1">
85
+
86
+ <b>Stay tuned to our updates :</b>
87
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
88
+
89
+ Name :
90
+ <input style="border: 1px solid #3fafe3; margin-right:10px;" type="text" name="field1" value="<?php
91
+ if ($current_user->user_firstname != "" || $current_user->user_lastname != "")
92
+ {
93
+ echo $current_user->user_firstname . " " . $current_user->user_lastname;
94
+ }
95
+ else if (strcasecmp($current_user->display_name, 'admin')!=0 && strcasecmp($current_user->display_name , "administrator")!=0 )
96
+ {
97
+ echo $current_user->display_name;
98
+ }
99
+ else if (strcasecmp($current_user->user_login ,"admin")!=0 && strcasecmp($current_user->user_login , "administrator")!=0 )
100
+ {
101
+ echo $current_user->user_login;
102
+ }
103
+ ?>" >
104
+
105
+ Email Address :
106
+ <input style="border: 1px solid #3fafe3;" name="email"
107
+ type="text" value="<?php echo $current_user->user_email; ?>" /><span style="color:#FF0000">*</span>
108
+
109
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
110
+ <input id="submit_ips" style="color:#FFFFFF;border-radius:4px;border:1px solid #1A87B9;" type="submit" value="Subscribe" name="Submit" onclick="javascript: if(!verify_fields()) return false; " />
111
+
112
+ <input type="hidden" name="listName" value="6,1,"/>
113
+ </form>
114
+
115
+
116
+
117
+ </div>
118
+
119
+
120
+ <div style="clear: both;"></div>
121
+ <div style="width: 100%">
122
+
123
+ <div class="xyz_our_plugins">
124
+ See Also :
125
+
126
+ <a target="_blank" href="http://wordpress.org/extend/plugins/lightbox-pop/">Lightbox Pop</a> ★
127
+ <a target="_blank" href="http://wordpress.org/extend/plugins/full-screen-popup/">Full Screen Popup</a> ★
128
+ <a target="_blank" href="http://wordpress.org/extend/plugins/popup-dialog-box/">Popup Dialog Box</a> ★
129
+ <a target="_blank" href="http://wordpress.org/extend/plugins/quick-bar/">Quick Bar</a> ★
130
+ <a target="_blank" href="http://wordpress.org/extend/plugins/quick-box-popup/">Quick Box Popup</a> ★
131
+ <a target="_blank" href="http://wordpress.org/extend/plugins/contact-form-manager/">Contact Form Manager</a> ★
132
+ <a target="_blank" href="http://wordpress.org/extend/plugins/newsletter-manager/">Newsletter Manager</a> ★
133
+ <a target="_blank" href="http://wordpress.org/extend/plugins/social-media-auto-publish/">Social Media Auto Publish</a>
134
+
135
+ </div>
136
+ </div>
137
+ <div class="poweredBy">
138
+ Powered by <a href="http://xyzscripts.com" target="_blank">XYZScripts</a>
139
+ </div>
140
+ <div style="clear: both;"></div>
141
+
142
+ </div>
143
+ <p style="clear: both;"></p>
admin/header.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ a.xyz_header_link:hover{text-decoration:underline;}
3
+ .xyz_header_link{text-decoration:none;}
4
+ </style>
5
+
6
+ <?php
7
+
8
+ if(get_option('xyz_credit_link')=="0"){
9
+ ?>
10
+ <div style="float:left;background-color: #FFECB3;border-radius:5px;padding: 0px 5px;margin-top: 10px;border: 1px solid #E0AB1B" id="xyz_backlink_div">
11
+
12
+ Please do a favour by enabling backlink to our site. <a id="xyz_ips_backlink" style="cursor: pointer;" >Okay, Enable</a>.
13
+ <script type="text/javascript">
14
+
15
+ jQuery(document).ready(function() {
16
+
17
+ jQuery('#xyz_ips_backlink').click(function() {
18
+ var dataString = {
19
+ action: 'ajax_backlink',
20
+ enable: 1
21
+ };
22
+
23
+ jQuery.post(ajaxurl, dataString, function(response) {
24
+ jQuery("#xyz_backlink_div").html('Thank you for enabling backlink !');
25
+ jQuery("#xyz_backlink_div").css('background-color', '#D8E8DA');
26
+ jQuery("#xyz_backlink_div").css('border', '1px solid #0F801C');
27
+ });
28
+ });
29
+ });
30
+
31
+ </script>
32
+ </div>
33
+ <?php
34
+ }
35
+ ?>
36
+
37
+ <style>
38
+ #text {margin:50px auto; width:500px}
39
+ .hotspot {color:#900; padding-bottom:1px; border-bottom:1px dotted #900; cursor:pointer}
40
+
41
+ #tt {position:absolute; display:block; }
42
+ #tttop {display:block; height:5px; margin-left:5px;}
43
+ #ttcont {display:block; padding:2px 10px 3px 7px; margin-left:-400px; background:#666; color:#FFF}
44
+ #ttbot {display:block; height:5px; margin-left:5px; }
45
+ </style>
46
+
47
+
48
+
49
+
50
+
51
+ <div style="margin-top: 10px">
52
+ <table style="float:right; ">
53
+ <tr>
54
+ <td style="float:right;" >
55
+ <a onmouseover="tooltip.show('Please help us to keep this plugin free forever by donating a dollar');" onmouseout="tooltip.hide();" class="xyz_header_link" style="margin-left:8px;margin-right:12px;" target="_blank" href="http://xyzscripts.com/donate/1">Donate</a>
56
+ </td>
57
+ <td style="float:right;">
58
+ <a class="xyz_header_link" style="margin-left:8px;" target="_blank" href="http://kb.xyzscripts.com/category/insert-php-code-snippet/">FAQ</a>
59
+ </td>
60
+ <td style="float:right;">
61
+ <a class="xyz_header_link" style="margin-left:8px;" target="_blank" href="http://docs.xyzscripts.com/category/insert-php-code-snippet/">Docs</a>
62
+ </td>
63
+ <td style="float:right;">
64
+ <a class="xyz_header_link" style="margin-left:8px;" target="_blank" href="http://xyzscripts.com/wordpress-plugins/insert-php-code-snippet/details">About</a>
65
+ </td>
66
+ <td style="float:right;">
67
+ <a class="xyz_header_link" target="_blank" href="http://xyzscripts.com">XYZScripts</a>
68
+ </td>
69
+
70
+ </tr>
71
+ </table>
72
+ </div>
73
+
74
+ <div style="clear: both"></div>
admin/install.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function xyz_ips_network_install($networkwide) {
4
+ global $wpdb;
5
+
6
+ if (function_exists('is_multisite') && is_multisite()) {
7
+ // check if it is a network activation - if so, run the activation function for each blog id
8
+ if ($networkwide) {
9
+ $old_blog = $wpdb->blogid;
10
+ // Get all blog ids
11
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
12
+ foreach ($blogids as $blog_id) {
13
+ switch_to_blog($blog_id);
14
+ xyz_ips_install();
15
+ }
16
+ switch_to_blog($old_blog);
17
+ return;
18
+ }
19
+ }
20
+ xyz_ips_install();
21
+ }
22
+
23
+
24
+ function xyz_ips_install(){
25
+
26
+ global $wpdb;
27
+ //global $current_user; get_currentuserinfo();
28
+
29
+
30
+ if(get_option('xyz_credit_link') == "")
31
+ {
32
+ add_option("xyz_credit_link",0);
33
+ }
34
+
35
+ add_option('xyz_ips_limit',20);
36
+ $queryInsertPhp = "CREATE TABLE IF NOT EXISTS ".$wpdb->prefix."xyz_ips_short_code (
37
+ `id` int NOT NULL AUTO_INCREMENT,
38
+ `title` varchar(1000) COLLATE utf8_unicode_ci NOT NULL,
39
+ `content` longtext COLLATE utf8_unicode_ci NOT NULL,
40
+ `short_code` varchar(2000) COLLATE utf8_unicode_ci NOT NULL,
41
+ `status` int NOT NULL,
42
+ PRIMARY KEY (`id`)
43
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1";
44
+ $wpdb->query($queryInsertPhp);
45
+ }
46
+
47
+ register_activation_hook( XYZ_INSERT_PHP_PLUGIN_FILE ,'xyz_ips_network_install');
48
+
49
+
50
+
51
+
52
+
admin/menu.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action('admin_menu', 'xyz_ips_menu');
4
+
5
+
6
+ function xyz_ips_menu(){
7
+
8
+ add_menu_page('insert-php-code-snippet', 'XYZ PHP Code', 'manage_options', 'insert-php-code-snippet-manage','xyz_ips_snippets',plugins_url('insert-php-code-snippet/images/logo.png'));
9
+
10
+ add_submenu_page('insert-php-code-snippet-manage', 'PHPCode Snippets', 'PHPCode Snippets', 'manage_options', 'insert-php-code-snippet-manage','xyz_ips_snippets');
11
+ add_submenu_page('insert-php-code-snippet-manage', 'PHPCode Snippets - Manage settings', 'Settings', 'manage_options', 'insert-php-code-snippet-settings' ,'xyz_ips_settings');
12
+ add_submenu_page('insert-php-code-snippet-manage', 'PHPCode Snippets - About', 'About', 'manage_options', 'insert-php-code-snippet-about' ,'xyz_ips_about');
13
+
14
+ }
15
+
16
+ function xyz_ips_snippets(){
17
+ $formflag = 0;
18
+ if(isset($_GET['action']) && $_GET['action']=='snippet-delete' )
19
+ {
20
+ include(dirname( __FILE__ ) . '/snippet-delete.php');
21
+ $formflag=1;
22
+ }
23
+ if(isset($_GET['action']) && $_GET['action']=='snippet-edit' )
24
+ {
25
+ require( dirname( __FILE__ ) . '/header.php' );
26
+ include(dirname( __FILE__ ) . '/snippet-edit.php');
27
+ require( dirname( __FILE__ ) . '/footer.php' );
28
+ $formflag=1;
29
+ }
30
+ if(isset($_GET['action']) && $_GET['action']=='snippet-add' )
31
+ {
32
+ require( dirname( __FILE__ ) . '/header.php' );
33
+ require( dirname( __FILE__ ) . '/snippet-add.php' );
34
+ require( dirname( __FILE__ ) . '/footer.php' );
35
+ $formflag=1;
36
+ }
37
+ if(isset($_GET['action']) && $_GET['action']=='snippet-status' )
38
+ {
39
+ require( dirname( __FILE__ ) . '/snippet-status.php' );
40
+ $formflag=1;
41
+ }
42
+ if($formflag == 0){
43
+ require( dirname( __FILE__ ) . '/header.php' );
44
+ require( dirname( __FILE__ ) . '/snippets.php' );
45
+ require( dirname( __FILE__ ) . '/footer.php' );
46
+ }
47
+ }
48
+
49
+ function xyz_ips_settings()
50
+ {
51
+ require( dirname( __FILE__ ) . '/header.php' );
52
+ require( dirname( __FILE__ ) . '/settings.php' );
53
+ require( dirname( __FILE__ ) . '/footer.php' );
54
+
55
+ }
56
+
57
+ function xyz_ips_about(){
58
+ require( dirname( __FILE__ ) . '/header.php' );
59
+ require( dirname( __FILE__ ) . '/about.php' );
60
+ require( dirname( __FILE__ ) . '/footer.php' );
61
+ }
62
+
63
+
64
+ function xyz_ips_add_style_script(){
65
+
66
+ wp_enqueue_script('jquery');
67
+
68
+ wp_register_script( 'xyz_notice_script', plugins_url('insert-php-code-snippet/js/notice.js') );
69
+ wp_enqueue_script( 'xyz_notice_script' );
70
+
71
+ // Register stylesheets
72
+ wp_register_style('xyz_ips_style', plugins_url('insert-php-code-snippet/css/xyz_ips_styles.css'));
73
+ wp_enqueue_style('xyz_ips_style');
74
+ }
75
+ add_action('admin_enqueue_scripts', 'xyz_ips_add_style_script');
76
+
77
+
78
+
79
+
80
+ ?>
admin/settings.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $wpdb;
4
+ // Load the options
5
+
6
+
7
+ if($_POST){
8
+
9
+ $_POST=xyz_trim_deep($_POST);
10
+ $_POST = stripslashes_deep($_POST);
11
+
12
+ $xyz_ips_limit = abs(intval($_POST['xyz_ips_limit']));
13
+ if($xyz_ips_limit==0)$xyz_ips_limit=20;
14
+
15
+ $xyz_ips_credit = $_POST['xyz_ips_credit'];
16
+
17
+
18
+ update_option('xyz_ips_limit',$xyz_ips_limit);
19
+ update_option('xyz_credit_link',$xyz_ips_credit);
20
+
21
+ ?>
22
+
23
+ <div class="system_notice_area_style1" id="system_notice_area">
24
+ Settings updated successfully. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
25
+ </div>
26
+ <?php
27
+ }
28
+
29
+
30
+ ?>
31
+
32
+ <div>
33
+
34
+
35
+ <form method="post">
36
+ <div style="float: left;width: 98%">
37
+ <fieldset style=" width:100%; border:1px solid #F7F7F7; padding:10px 0px 15px 10px;">
38
+ <legend ><h3>Settings</h3></legend>
39
+ <table class="widefat" style="width:99%;">
40
+ <tr valign="top">
41
+ <td scope="row" ><label for="xyz_ips_credit">Credit link to author</label>
42
+ </td>
43
+ <td><select name="xyz_ips_credit" id="xyz_ips_credit">
44
+ <option value="ips"
45
+ <?php if(isset($_POST['xyz_ips_credit']) && $_POST['xyz_ips_credit']=='ips') { echo 'selected';}elseif(get_option('xyz_credit_link')=="ips"){echo 'selected';} ?>>Enable</option>
46
+ <option value="0"
47
+ <?php if(isset($_POST['xyz_ips_credit']) && $_POST['xyz_ips_credit']!='ips') { echo 'selected';}elseif(get_option('xyz_credit_link')!="ips"){echo 'selected';} ?>>Disable</option>
48
+
49
+ </select>
50
+ </td>
51
+ </tr>
52
+
53
+ <tr valign="top">
54
+ <td scope="row" class=" settingInput" id=""><label for="xyz_ips_limit">Pagination limit</label></td>
55
+ <td id=""><input name="xyz_ips_limit" type="text"
56
+ 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'));} ?>" />
57
+ </td>
58
+ </tr>
59
+
60
+ <tr valign="top">
61
+ <td scope="row" class=" settingInput" id="bottomBorderNone">
62
+ </td>
63
+ <td id="bottomBorderNone"><input style="margin:10px 0 20px 0;" id="submit" class="button-primary bottonWidth" type="submit" value=" Update Settings " />
64
+ </td>
65
+ </tr>
66
+
67
+ </table>
68
+ </fieldset>
69
+
70
+ </div>
71
+
72
+ </form>
73
+ </div>
admin/snippet-add.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $wpdb;
4
+
5
+ $_POST = stripslashes_deep($_POST);
6
+ $_POST = xyz_trim_deep($_POST);
7
+
8
+ if(isset($_POST) && isset($_POST['addSubmit'])){
9
+
10
+ // echo '<pre>';
11
+ // print_r($_POST);
12
+ // die("JJJ");
13
+
14
+ $temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
15
+ $temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
16
+
17
+ $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
18
+
19
+
20
+ $xyz_ips_content = $_POST['snippetContent'];
21
+
22
+ if($xyz_ips_title != "" && $xyz_ips_content != ""){
23
+
24
+ if(ctype_alnum($temp_xyz_ips_title)){
25
+
26
+ $snippet_count = $wpdb->query( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE title="'.$xyz_ips_title.'"' ) ;
27
+ if($snippet_count == 0){
28
+ $xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
29
+ $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'));
30
+
31
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=1'));
32
+ }else{
33
+ ?>
34
+ <div class="system_notice_area_style0" id="system_notice_area">
35
+ PHP Snippet already exists. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
36
+ </div>
37
+ <?php
38
+ }
39
+ }else{
40
+ ?>
41
+ <div class="system_notice_area_style0" id="system_notice_area">
42
+ PHP Snippet title must be alphanumeric. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
43
+ </div>
44
+ <?php
45
+ }
46
+ }else{
47
+ ?>
48
+ <div class="system_notice_area_style0" id="system_notice_area">
49
+ Fill all mandatory fields. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ }
55
+
56
+ ?>
57
+
58
+ <div >
59
+ <fieldset
60
+ style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
61
+ <legend>
62
+ <b>Add PHP Snippet</b>
63
+ </legend>
64
+ <form name="frmmainForm" id="frmmainForm" method="post">
65
+
66
+ <div>
67
+ <table
68
+ style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
69
+ <tr><td><br/>
70
+ <div id="shortCode"></div>
71
+ <br/></td></tr>
72
+ <tr valign="top">
73
+ <td style="border-bottom: none;width:20%;">&nbsp;&nbsp;&nbsp;Tracking Name&nbsp;<font color="red">*</font></td>
74
+ <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
75
+ <td><input style="width:80%;"
76
+ type="text" name="snippetTitle" id="snippetTitle"
77
+ value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}?>"></td>
78
+ </tr>
79
+ <tr>
80
+ <td style="border-bottom: none;width:20%; ">&nbsp;&nbsp;&nbsp;PHP code (without &lt;?php ?&gt;)&nbsp;<font color="red">*</font></td>
81
+ <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
82
+ <td >
83
+ <textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}?></textarea>
84
+ </td>
85
+ </tr>
86
+
87
+ <tr>
88
+ <td></td><td></td>
89
+ <td><input class="button-primary" style="cursor: pointer;"
90
+ type="submit" name="addSubmit" value="Create"></td>
91
+ </tr>
92
+ <tr><td><br/></td></tr>
93
+ </table>
94
+ </div>
95
+
96
+ </form>
97
+ </fieldset>
98
+
99
+ </div>
admin/snippet-delete.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb;
3
+
4
+ $_POST = stripslashes_deep($_POST);
5
+ $_GET = stripslashes_deep($_GET);
6
+
7
+ $xyz_ips_snippetId = intval($_GET['snippetId']);
8
+ $xyz_ips_pageno = intval($_GET['pageno']);
9
+
10
+ if($xyz_ips_snippetId=="" || !is_numeric($xyz_ips_snippetId)){
11
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage'));
12
+ exit();
13
+
14
+ }
15
+ $snippetCount = $wpdb->query( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id="'.$xyz_ips_snippetId.'" LIMIT 0,1' ) ;
16
+
17
+ if($snippetCount==0){
18
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=2'));
19
+ exit();
20
+ }else{
21
+
22
+ $wpdb->query( 'DELETE FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id="'.$xyz_ips_snippetId.'" ' ) ;
23
+
24
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=3&pagenum='.$xyz_ips_pageno));
25
+ exit();
26
+
27
+ }
28
+ ?>
admin/snippet-edit.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $wpdb;
4
+ global $current_user;
5
+ get_currentuserinfo();
6
+
7
+ $xyz_ips_snippetId = $_GET['snippetId'];
8
+
9
+ if(isset($_POST) && isset($_POST['updateSubmit'])){
10
+
11
+ // echo '<pre>';
12
+ // print_r($_POST);
13
+ // die("JJJ");
14
+ $_POST = stripslashes_deep($_POST);
15
+ $_POST = xyz_trim_deep($_POST);
16
+
17
+ $xyz_ips_snippetId = $_GET['snippetId'];
18
+ $temp_xyz_ips_title = str_replace(' ', '', $_POST['snippetTitle']);
19
+ $temp_xyz_ips_title = str_replace('-', '', $temp_xyz_ips_title);
20
+ $xyz_ips_title = str_replace(' ', '-', $_POST['snippetTitle']);
21
+ $xyz_ips_content = $_POST['snippetContent'];
22
+
23
+ if($xyz_ips_title != "" && $xyz_ips_content != ""){
24
+
25
+ if(ctype_alnum($temp_xyz_ips_title))
26
+ {
27
+ $snippet_count = $wpdb->query( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id!="'.$xyz_ips_snippetId.'" AND title="'.$xyz_ips_title.'" LIMIT 0,1' ) ;
28
+
29
+ if($snippet_count == 0){
30
+ $xyz_shortCode = '[xyz-ips snippet="'.$xyz_ips_title.'"]';
31
+
32
+ $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));
33
+
34
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&msg=5'));
35
+
36
+ }else{
37
+ ?>
38
+ <div class="system_notice_area_style0" id="system_notice_area">
39
+ PHP Snippet already exists. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
40
+ </div>
41
+ <?php
42
+
43
+ }
44
+ }
45
+ else
46
+ {
47
+ ?>
48
+ <div class="system_notice_area_style0" id="system_notice_area">
49
+ PHP Snippet title must be alphanumeric. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
50
+ </div>
51
+ <?php
52
+
53
+ }
54
+
55
+
56
+ }else{
57
+ ?>
58
+ <div class="system_notice_area_style0" id="system_notice_area">
59
+ Fill all mandatory fields. &nbsp;&nbsp;&nbsp;<span id="system_notice_area_dismiss">Dismiss</span>
60
+ </div>
61
+ <?php
62
+ }
63
+
64
+ }
65
+
66
+
67
+ global $wpdb;
68
+
69
+
70
+ $snippetDetails = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id="'.$xyz_ips_snippetId.'" LIMIT 0,1' ) ;
71
+ $snippetDetails = $snippetDetails[0];
72
+
73
+ ?>
74
+
75
+ <div >
76
+ <fieldset
77
+ style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
78
+ <legend>
79
+ <b>Edit PHP Snippet</b>
80
+ </legend>
81
+ <form name="frmmainForm" id="frmmainForm" method="post">
82
+ <input type="hidden" id="snippetId" name="snippetId"
83
+ value="<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
84
+ <div>
85
+ <table
86
+ style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
87
+ <tr><td><br/>
88
+ <div id="shortCode"></div>
89
+ <br/></td></tr>
90
+ <tr valign="top">
91
+ <td style="border-bottom: none;width:20%;">&nbsp;&nbsp;&nbsp;Tracking Name&nbsp;<font color="red">*</font></td>
92
+ <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
93
+ <td><input style="width:80%;"
94
+ type="text" name="snippetTitle" id="snippetTitle"
95
+ value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td>
96
+ </tr>
97
+ <tr>
98
+ <td style="border-bottom: none;width:20%; ">&nbsp;&nbsp;&nbsp;PHP code (without &lt;?php ?&gt;)&nbsp;<font color="red">*</font></td>
99
+ <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
100
+ <td >
101
+ <textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}else{ echo esc_textarea($snippetDetails->content); }?></textarea>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <td></td><td></td>
107
+ <td><input class="button-primary" style="cursor: pointer;"
108
+ type="submit" name="updateSubmit" value="Update"></td>
109
+ </tr>
110
+ <tr><td><br/></td></tr>
111
+ </table>
112
+ </div>
113
+
114
+ </form>
115
+ </fieldset>
116
+
117
+ </div>
admin/snippet-status.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $wpdb;
4
+
5
+ $_POST = stripslashes_deep($_POST);
6
+ $_GET = stripslashes_deep($_GET);
7
+
8
+ $xyz_ips_snippetId = intval($_GET['snippetId']);
9
+ $xyz_ips_snippetStatus = intval($_GET['status']);
10
+ $xyz_ips_pageno = intval($_GET['pageno']);
11
+ if($xyz_ips_snippetId=="" || !is_numeric($xyz_ips_snippetId)){
12
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage'));
13
+ exit();
14
+
15
+ }
16
+
17
+ $snippetCount = $wpdb->query( 'SELECT * FROM '.$wpdb->prefix.'xyz_ips_short_code WHERE id="'.$xyz_ips_snippetId.'" LIMIT 0,1' ) ;
18
+
19
+ if($snippetCount==0){
20
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=2'));
21
+ exit();
22
+ }else{
23
+
24
+ $wpdb->update($wpdb->prefix.'xyz_ips_short_code', array('status'=>$xyz_ips_snippetStatus), array('id'=>$xyz_ips_snippetId));
25
+ header("Location:".admin_url('admin.php?page=insert-php-code-snippet-manage&xyz_ips_msg=4&pagenum='.$xyz_ips_pageno));
26
+ exit();
27
+
28
+ }
29
+ ?>
admin/snippets.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb;
3
+ $_GET = stripslashes_deep($_GET);
4
+ $xyz_ips_message = '';
5
+ if(isset($_GET['xyz_ips_msg'])){
6
+ $xyz_ips_message = $_GET['xyz_ips_msg'];
7
+ }
8
+ if($xyz_ips_message == 1){
9
+
10
+ ?>
11
+ <div class="system_notice_area_style1" id="system_notice_area">
12
+ PHP Snippet successfully added.&nbsp;&nbsp;&nbsp;<span
13
+ id="system_notice_area_dismiss">Dismiss</span>
14
+ </div>
15
+ <?php
16
+
17
+ }
18
+ if($xyz_ips_message == 2){
19
+
20
+ ?>
21
+ <div class="system_notice_area_style0" id="system_notice_area">
22
+ PHP Snippet not found.&nbsp;&nbsp;&nbsp;<span
23
+ id="system_notice_area_dismiss">Dismiss</span>
24
+ </div>
25
+ <?php
26
+
27
+ }
28
+ if($xyz_ips_message == 3){
29
+
30
+ ?>
31
+ <div class="system_notice_area_style1" id="system_notice_area">
32
+ PHP Snippet successfully deleted.&nbsp;&nbsp;&nbsp;<span
33
+ id="system_notice_area_dismiss">Dismiss</span>
34
+ </div>
35
+ <?php
36
+
37
+ }
38
+ if($xyz_ips_message == 4){
39
+
40
+ ?>
41
+ <div class="system_notice_area_style1" id="system_notice_area">
42
+ PHP Snippet status successfully changed.&nbsp;&nbsp;&nbsp;<span
43
+ id="system_notice_area_dismiss">Dismiss</span>
44
+ </div>
45
+ <?php
46
+
47
+ }
48
+ if($xyz_ips_message == 5){
49
+
50
+ ?>
51
+ <div class="system_notice_area_style1" id="system_notice_area">
52
+ PHP Snippet successfully updated.&nbsp;&nbsp;&nbsp;<span
53
+ id="system_notice_area_dismiss">Dismiss</span>
54
+ </div>
55
+ <?php
56
+
57
+ }
58
+ ?>
59
+
60
+
61
+ <div >
62
+
63
+
64
+ <form method="post">
65
+ <fieldset
66
+ style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
67
+ <legend><h3>PHP Code Snippets</h3></legend>
68
+ <?php
69
+ global $wpdb;
70
+ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
71
+ $limit = get_option('xyz_ips_limit');
72
+ $offset = ( $pagenum - 1 ) * $limit;
73
+
74
+
75
+ $entries = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code ORDER BY id DESC LIMIT $offset,$limit" );
76
+
77
+ ?>
78
+ <input id="submit_ips"
79
+ style="cursor: pointer; margin-bottom:10px; margin-left:8px;" type="button"
80
+ name="textFieldButton2" value="Add New PHP Code Snippet"
81
+ onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'>
82
+ <table class="widefat" style="width: 99%; margin: 0 auto; border-bottom:none;">
83
+ <thead>
84
+ <tr>
85
+ <th scope="col" >Tracking Name</th>
86
+ <th scope="col" >Snippet Short Code</th>
87
+ <th scope="col" >Status</th>
88
+ <th scope="col" colspan="3" style="text-align: center;">Action</th>
89
+ </tr>
90
+ </thead>
91
+ <tbody>
92
+ <?php
93
+ if( count($entries)>0 ) {
94
+ $count=1;
95
+ $class = '';
96
+ foreach( $entries as $entry ) {
97
+ $class = ( $count % 2 == 0 ) ? ' class="alternate"' : '';
98
+ ?>
99
+ <tr <?php echo $class; ?>>
100
+ <td id="vAlign"><?php
101
+ echo esc_html($entry->title);
102
+ ?></td>
103
+ <td id="vAlign"><?php
104
+ if($entry->status == 2){echo 'NA';}
105
+ else
106
+ echo '[xyz-ips snippet="'.esc_html($entry->title).'"]';
107
+ ?></td>
108
+ <td id="vAlign">
109
+ <?php
110
+ if($entry->status == 2){
111
+ echo "Inactive";
112
+ }elseif ($entry->status == 1){
113
+ echo "Active";
114
+ }
115
+
116
+ ?>
117
+ </td>
118
+ <?php
119
+ if($entry->status == 2){
120
+ ?>
121
+ <td style="text-align: center;"><a
122
+ href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$entry->id.'&status=1&pageno='.$pagenum); ?>'><img
123
+ id="img" title="Activate"
124
+ src="<?php echo plugins_url('insert-php-code-snippet/images/activate.png')?>">
125
+ </a>
126
+ </td>
127
+ <?php
128
+ }elseif ($entry->status == 1){
129
+ ?>
130
+ <td style="text-align: center;"><a
131
+ href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-status&snippetId='.$entry->id.'&status=2&pageno='.$pagenum); ?>'><img
132
+ id="img" title="Deactivate"
133
+ src="<?php echo plugins_url('insert-php-code-snippet/images/pause.png')?>">
134
+ </a>
135
+ </td>
136
+ <?php
137
+ }
138
+
139
+ ?>
140
+
141
+ <td style="text-align: center;"><a
142
+ href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-edit&snippetId='.$entry->id.'&pageno='.$pagenum); ?>'><img
143
+ id="img" title="Edit Snippet"
144
+ src="<?php echo plugins_url('insert-php-code-snippet/images/edit.png')?>">
145
+ </a>
146
+ </td>
147
+ <td style="text-align: center;" ><a
148
+ href='<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-delete&snippetId='.$entry->id.'&pageno='.$pagenum); ?>'
149
+ onclick="javascript: return confirm('Please click \'OK\' to confirm ');"><img
150
+ id="img" title="Delete Snippet"
151
+ src="<?php echo plugins_url('insert-php-code-snippet/images/delete.png')?>">
152
+ </a></td>
153
+ </tr>
154
+ <?php
155
+ $count++;
156
+ }
157
+ } else { ?>
158
+ <tr>
159
+ <td colspan="6" >PHP Code Snippets not found</td>
160
+ </tr>
161
+ <?php } ?>
162
+ </tbody>
163
+ </table>
164
+
165
+ <input id="submit_ips"
166
+ style="cursor: pointer; margin-top:10px;margin-left:8px;" type="button"
167
+ name="textFieldButton2" value="Add New PHP Code Snippet"
168
+ onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-php-code-snippet-manage&action=snippet-add');?>"'>
169
+
170
+ <?php
171
+ $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM ".$wpdb->prefix."xyz_ips_short_code" );
172
+ $num_of_pages = ceil( $total / $limit );
173
+
174
+ $page_links = paginate_links( array(
175
+ 'base' => add_query_arg( 'pagenum','%#%'),
176
+ 'format' => '',
177
+ 'prev_text' => '&laquo;',
178
+ 'next_text' => '&raquo;',
179
+ 'total' => $num_of_pages,
180
+ 'current' => $pagenum
181
+ ) );
182
+
183
+
184
+
185
+ if ( $page_links ) {
186
+ echo '<div class="tablenav" style="width:99%"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>';
187
+ }
188
+
189
+ ?>
190
+
191
+ </fieldset>
192
+
193
+ </form>
194
+
195
+ </div>
196
+
admin/uninstall.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function xyz_ips_network_uninstall($networkwide) {
4
+ global $wpdb;
5
+
6
+ if (function_exists('is_multisite') && is_multisite()) {
7
+ // check if it is a network activation - if so, run the activation function for each blog id
8
+ if ($networkwide) {
9
+ $old_blog = $wpdb->blogid;
10
+ // Get all blog ids
11
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
12
+ foreach ($blogids as $blog_id) {
13
+ switch_to_blog($blog_id);
14
+ xyz_ips_uninstall();
15
+ }
16
+ switch_to_blog($old_blog);
17
+ return;
18
+ }
19
+ }
20
+ xyz_ips_uninstall();
21
+ }
22
+
23
+ function xyz_ips_uninstall(){
24
+
25
+ global $wpdb;
26
+
27
+ delete_option("xyz_ips_limit");
28
+
29
+ /* table delete*/
30
+ $wpdb->query("DROP TABLE ".$wpdb->prefix."xyz_ips_short_code");
31
+
32
+
33
+ }
34
+
35
+ register_uninstall_hook( XYZ_INSERT_PHP_PLUGIN_FILE, 'xyz_ips_network_uninstall' );
36
+ ?>
ajax-handler.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( dirname( __FILE__ ) . '/admin/ajax-backlink.php' );
4
+
5
+ ?>
css/xyz_ips_styles.css ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #system_notice_area_dismiss{
3
+ color: #FFFFFF;
4
+ cursor: pointer;
5
+ }
6
+ .system_notice_area_style1 {
7
+ background: #00C348;
8
+ border: 1px solid green;
9
+ }
10
+
11
+ .system_notice_area_style0 {
12
+ background: #FA5A6A;
13
+ border: 1px solid brown;
14
+ }
15
+
16
+
17
+ #button {
18
+ width: 140px;
19
+ background-color: #E4E4E4;
20
+ cursor: pointer;
21
+ -webkit-border-radius: 40px;
22
+ -moz-border-radius: 40px;
23
+ border-radius: 40px;
24
+ }
25
+
26
+ #button:hover {
27
+ border: 1px solid #797979;
28
+ }
29
+
30
+ a {
31
+ text-decoration: none;
32
+ }
33
+
34
+ label{
35
+ cursor:default;
36
+ }
37
+
38
+ #img{
39
+ width:20px;
40
+ height: 20px;
41
+ }
42
+
43
+ #vAlign{
44
+ vertical-align: middle;
45
+ }
46
+
47
+ #tdCenter{
48
+ text-align: center;
49
+ }
50
+ .bottonWidth{
51
+ width:120px;
52
+ }
53
+ #buttonDesign{
54
+ width:120px;
55
+ }
56
+
57
+ #bottomBorderNone {
58
+ border-bottom:none;
59
+ }
60
+
61
+ legend{
62
+ font-size: 14px;
63
+ }
64
+ #content_xyz_ips_snippet_selecterList_text{
65
+ width:90px;
66
+ }
67
+
68
+ /*admin style*/
69
+
70
+ #system_notice_area {
71
+ position: fixed;
72
+ margin-bottom:40px;
73
+ left:25%;
74
+ width:50%;
75
+ height:20px;
76
+ border-radius:5px;
77
+ -moz-border-radius:5px;
78
+ -webkit-border-radius:5px;
79
+ font-weight:bold;
80
+ display:none;
81
+ padding:3px;
82
+ color: #000000;
83
+ text-align: center;
84
+ top: 0px;
85
+ z-index:100000;
86
+ }
87
+
88
+
89
+ .xyz_suggest,.xyz_star,.xyz_donate,.xyz_fbook,.xyz_support,.xyz_twitt,.xyz_gplus{
90
+ height:16px;
91
+ background-repeat: no-repeat;
92
+ background-position: left center;
93
+ padding-left: 15px;
94
+ text-decoration: none;
95
+
96
+ vertical-align: middle;
97
+ display: inline-block;
98
+
99
+ }
100
+
101
+ .xyz_suggest{
102
+
103
+ background-image: url('../images/suggest.png');
104
+ }
105
+
106
+ .xyz_star{
107
+ background-image: url('../images/star.png');
108
+ }
109
+
110
+ .xyz_donate{
111
+
112
+ background-image: url('../images/donate.png');
113
+ }
114
+
115
+
116
+ .xyz_fbook{
117
+
118
+ background-image: url('../images/facebook.png');
119
+ }
120
+ .xyz_support{
121
+
122
+ background-image: url('../images/support.png');
123
+ }
124
+ .xyz_twitt{
125
+
126
+ background-image: url('../images/twitter.png');
127
+ }
128
+ .xyz_gplus{
129
+
130
+ background-image: url('../images/gplus.png');
131
+ }
132
+
133
+
134
+ #insert-php-code-snippet .xyz_gplus{
135
+ margin-left: 3px;
136
+ }
137
+
138
+ #insert-php-code-snippet .plugin-version-author-uri {
139
+
140
+ background-color: #F4F4F4;
141
+ min-height:16px;
142
+ border-radius:5px;
143
+ margin-bottom: 10px;
144
+ font-weight:bold;
145
+ padding: 5px;
146
+ color: #111111;
147
+
148
+ -webkit-box-shadow: 0 8px 6px -6px black;
149
+ -moz-box-shadow: 0 8px 6px -6px black;
150
+ box-shadow: 0 8px 6px -6px black;
151
+
152
+ }
153
+ #insert-php-code-snippet{
154
+ background: #a9e8f5; /* Old browsers */
155
+
156
+ background: -moz-linear-gradient(top, #ffffff 0%, #a9e8f5 100%); /* FF3.6+ */
157
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#a9e8f5)); /* Chrome,Safari4+ */
158
+ background: -webkit-linear-gradient(top, #ffffff 0%,#a9e8f5 100%); /* Chrome10+,Safari5.1+ */
159
+ background: -o-linear-gradient(top, #ffffff 0%,#a9e8f5 100%); /* Opera 11.10+ */
160
+ background: -ms-linear-gradient(top, #ffffff 0%,#a9e8f5 100%); /* IE10+ */
161
+ background: linear-gradient(top, #ffffff 0%,#a9e8f5 100%); /* W3C */
162
+
163
+
164
+ }
165
+ #insert-php-code-snippet .plugin-version-author-uri a,
166
+ #insert-php-code-snippet .plugin-version-author-uri a:link,
167
+ #insert-php-code-snippet .plugin-version-author-uri a:hover,
168
+ #insert-php-code-snippet .plugin-version-author-uri a:active,
169
+ #insert-php-code-snippet .plugin-version-author-uri a:visited{
170
+
171
+
172
+ color: #111111;
173
+ text-decoration: none;
174
+
175
+ }
176
+ #insert-php-code-snippet .plugin-version-author-uri a:hover{
177
+
178
+ color:#cc811a;
179
+ }
180
+ #insert-php-code-snippet .plugin-title{
181
+
182
+ background-image: url('../images/xyz_logo.png');
183
+ background-repeat: no-repeat;
184
+ background-position: left bottom;
185
+
186
+ }
187
+
188
+
189
+ #submit_ips{
190
+ background:#25A6E1;
191
+ background:-moz-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
192
+ background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#25A6E1),color-stop(100%,#188BC0));
193
+ background:-webkit-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
194
+ background:-o-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
195
+ background:-ms-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
196
+ background:linear-gradient(top,#25A6E1 0%,#188BC0 100%);
197
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#25A6E1",endColorstr="#188BC0",GradientType=0);
198
+ padding:1px 13px;
199
+ color:#ffffff;
200
+ font-family:"Helvetica Neue",sans-serif;
201
+ font-size:15px;
202
+ cursor:pointer;
203
+ border: 1px solid #1A87B9;
204
+ border-radius: 4px 4px 4px 4px;
205
+ font-weight: normal;
206
+ font-size: 13px;
207
+ }
208
+
209
+ .xyz_our_plugins{
210
+ background: #F2F2F2; /* Old browsers */
211
+ border: 1px solid #DFDFDF;
212
+ border-radius:3px;
213
+ width: 98%;
214
+ padding-left: 10px;
215
+ padding-top:10px;
216
+ height:30px;
217
+ margin-top:13px;
218
+ }
219
+
220
+ .xyz_our_plugins a{
221
+ text-decoration: none;
222
+ }
223
+
224
+ .poweredBy{
225
+ padding-top: 10px;float:left; text-align: center; width: 100%;
226
+ }
227
+
228
+ .poweredBy a{
229
+ text-decoration: none;
230
+ }
231
+
232
+ .xyz_feedback{
233
+ background: #CEEAF7; /* Old browsers */
234
+ border: 1px solid #64cfe8;
235
+ border-radius:3px;
236
+ width: 98%;
237
+ height:30px;
238
+ padding-top:10px;
239
+ padding-left: 10px;
240
+ font-weight: bold;
241
+ line-height: 20px;
242
+ }
243
+
244
+
245
+ .xyz_feedback a{
246
+ text-decoration: none
247
+ }
248
+
249
+
250
+ .xyz_subscribe{
251
+ background: #bae598; /* Old browsers */
252
+ border: 1px solid #4d8a1d;
253
+ border-radius:3px;
254
+ width: 98%;
255
+ height:35px;
256
+ padding-top:10px;
257
+ padding-left: 10px;
258
+ }
259
+ .xyz_subscribe td{
260
+ padding:0;
261
+ }
262
+
direct_call.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function xyz_ips_plugin_query_vars($vars) {
3
+ $vars[] = 'wp_ips';
4
+ return $vars;
5
+ }
6
+ add_filter('query_vars', 'xyz_ips_plugin_query_vars');
7
+
8
+
9
+ function xyz_ips_plugin_parse_request($wp) {
10
+ /*confirmation*/
11
+ if (array_key_exists('wp_ips', $wp->query_vars) && $wp->query_vars['wp_ips'] == 'editor_plugin_js') {
12
+ require( dirname( __FILE__ ) . '/editor_plugin.js.php' );
13
+ die;
14
+ }
15
+
16
+ }
17
+ add_action('parse_request', 'xyz_ips_plugin_parse_request');
editor_plugin.js.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! is_user_logged_in() )
4
+ die('You must be logged in to access this script.');
5
+
6
+ if(!isset($shortcodesXYZEP))
7
+ $shortcodesXYZEP = new XYZ_Insert_Php_TinyMCESelector();
8
+
9
+ global $wpdb;
10
+ // $ordered_sct = array_keys($shortcode_tags);
11
+ // sort($ordered_sct);
12
+
13
+ $ordered_sct = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status='1' ORDER BY id DESC" );
14
+ ?>
15
+
16
+ (function() {
17
+ //******* Load plugin specific language pack
18
+
19
+ tinymce.create('tinymce.plugins.<?php echo $shortcodesXYZEP->buttonName; ?>', {
20
+ /**
21
+ * Initializes the plugin, this will be executed after the plugin has been created.
22
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
23
+ * of the editor instance to intercept that event.
24
+ *
25
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
26
+ * @param {string} url Absolute URL to where the plugin is located.
27
+ */
28
+ init : function(ed, url) {
29
+
30
+ },
31
+
32
+ /**
33
+ * Creates control instances based in the incomming name. This method is normally not
34
+ * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
35
+ * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
36
+ * method can be used to create those.
37
+ *
38
+ * @param {String} n Name of the control to create.
39
+ * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
40
+ * @return {tinymce.ui.Control} New control instance or null if no control was created.
41
+ */
42
+ createControl : function(n, cm) {
43
+ if(n=='<?php echo $shortcodesXYZEP->buttonName; ?>'){
44
+ var mlb = cm.createListBox('<?php echo $shortcodesXYZEP->buttonName; ?>List', {
45
+ title : 'PHP Snippets',
46
+ onselect : function(v) { //Option value as parameter
47
+ if(v != ''){
48
+ if(tinyMCE.activeEditor.selection.getContent() != ''){
49
+ tinyMCE.activeEditor.selection.setContent('[' + v + ']' + tinyMCE.activeEditor.selection.getContent() + '[/' + v + ']');
50
+ }
51
+ else{
52
+ tinyMCE.activeEditor.selection.setContent('[' + v + ']');
53
+ }
54
+ }
55
+ }
56
+ });
57
+
58
+ // Add some values to the list box
59
+ <?php foreach($ordered_sct as $sct):?>
60
+ mlb.add('<?php echo $sct->title;?>', '<?php echo 'xyz-ips snippet="'.$sct->title.'"';?>');
61
+ <?php endforeach;?>
62
+
63
+ // Return the new listbox instance
64
+ return mlb;
65
+ }
66
+
67
+ return null;
68
+ },
69
+
70
+
71
+ });
72
+
73
+ // Register plugin
74
+ tinymce.PluginManager.add('<?php echo $shortcodesXYZEP->buttonName; ?>', tinymce.plugins.<?php echo $shortcodesXYZEP->buttonName; ?>);
75
+ })();
images/activate.png ADDED
Binary file
images/delete.png ADDED
Binary file
images/edit.png ADDED
Binary file
images/facebook.png ADDED
Binary file
images/gplus.png ADDED
Binary file
images/logo.png ADDED
Binary file
images/pause.png ADDED
Binary file
images/support.png ADDED
Binary file
images/twitter.png ADDED
Binary file
images/xyz_logo.png ADDED
Binary file
insert-php-code-snippet.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.0
7
+ Author: xyzscripts.com
8
+ Author URI: http://xyzscripts.com/
9
+ Text Domain: insert-php-code-snippet
10
+ License: GPLv2 or later
11
+ */
12
+
13
+ /*
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+ */
28
+
29
+ // if ( !function_exists( 'add_action' ) ) {
30
+ // echo "Hi there! I'm just a plugin, not much I can do when called directly.";
31
+ // exit;
32
+ // }
33
+
34
+ ob_start();
35
+
36
+ //error_reporting(E_ALL);
37
+
38
+ define('XYZ_INSERT_PHP_PLUGIN_FILE',__FILE__);
39
+
40
+ require( dirname( __FILE__ ) . '/xyz-functions.php' );
41
+
42
+ require( dirname( __FILE__ ) . '/add_shortcode_tynimce.php' );
43
+
44
+ require( dirname( __FILE__ ) . '/admin/install.php' );
45
+
46
+ require( dirname( __FILE__ ) . '/admin/menu.php' );
47
+
48
+ require( dirname( __FILE__ ) . '/shortcode-handler.php' );
49
+
50
+ require( dirname( __FILE__ ) . '/ajax-handler.php' );
51
+
52
+ require( dirname( __FILE__ ) . '/admin/uninstall.php' );
53
+
54
+ require( dirname( __FILE__ ) . '/widget.php' );
55
+
56
+ require( dirname( __FILE__ ) . '/direct_call.php' );
57
+
58
+
59
+
60
+ if(get_option('xyz_credit_link')=="ips"){
61
+
62
+ add_action('wp_footer', 'xyz_ips_credit');
63
+
64
+ }
65
+ function xyz_ips_credit() {
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 & Programs" href="http://www.xyzscripts.com" >XYZScripts.com</a></div>';
67
+ echo $content;
68
+ }
69
+
70
+
71
+ ?>
js/notice.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ jQuery('#system_notice_area').animate({
3
+ opacity : 'show',
4
+ height : 'show'
5
+ }, 500);
6
+
7
+ jQuery('#system_notice_area_dismiss').click(function() {
8
+ jQuery('#system_notice_area').animate({
9
+ opacity : 'hide',
10
+ height : 'hide'
11
+ }, 500);
12
+
13
+ });
14
+
15
+ });
readme.txt ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 3.4.2
8
+ Stable tag: 1.0
9
+ License: GPLv2 or later
10
+
11
+ Add PHP code to your pages and posts easily using shortcodes.
12
+
13
+ == Description ==
14
+
15
+ A quicklook into Insert PHP Code Snippet
16
+
17
+ ★ Convert PHP snippets to shortcodes
18
+ ★ Insert PHP code easily using shortcode
19
+ ★ Support for PHP snippet shortcodes in widgets
20
+ ★ Dropdown menu in TinyMCE editor to pick snippet shortcodes easily
21
+
22
+ = Features in Detail =
23
+
24
+ Insert PHP Code Snippet allows you to create shortcodes corresponding to PHP code snippets. You can create a shortcode corresponding to any random PHP code such as ad codes, login validation etc. and use the same in your posts, pages or widgets.
25
+
26
+ The shortcodes generated using the plugin are easily available as a dropdown in the standard wordpress content editor as well as in widget settings, thereby giving you ease of integrating your PHP snippets with your posts and pages.
27
+
28
+ = About =
29
+
30
+ Insert PHP Code Snippet is developed and maintained by [XYZScripts](http://xyzscripts.com/ "xyzscripts.com"). For any support, you may [contact us](http://xyzscripts.com/support/ "XYZScripts Support").
31
+
32
+ == Installation ==
33
+
34
+ 1. Extract `insert-php-code-snippet.zip` to your `/wp-content/plugins/` directory.
35
+ 2. In the admin panel under plugins activate Insert PHP Code Snippet.
36
+
37
+ If you need any further help, you may contact our [support desk](http://xyzscripts.com/support/ "XYZScripts Support").
38
+
39
+ == Frequently Asked Questions ==
40
+
41
+ = 1. The Insert PHP Code Snippet is not working properly. =
42
+
43
+ Please check the wordpress version you are using. Make sure it meets the minimum version recommended by us. Make sure all files of the `insert php code snippet` plugin uploaded to the folder `wp-content/plugins/`
44
+
45
+ = 2. I have 2 PHP shortcodes placed adjacently, but only one of them works. =
46
+
47
+ Please use a whitespace to separate 2 shortcodes.
48
+
49
+ More questions ? [Drop a mail](http://xyzscripts.com/members/support/ "XYZScripts Support") and we shall get back to you with the answers.
50
+
51
+
52
+ == Screenshots ==
53
+
54
+ 1. This is the shortcode generator page
55
+ 2. This is page where you can manage all your snippets
56
+ 3. The shortcodes are easily accessible in the content editor
57
+
58
+
59
+ == Changelog ==
60
+
61
+ = 1.0 =
62
+ * First official launch.
63
+
64
+ == Upgrade Notice ==
65
+ NA
66
+
67
+ == More Information ==
68
+
69
+
70
+ = Troubleshooting =
71
+
72
+ Please read the FAQ first if you are having problems.
73
+
74
+ = Requirements =
75
+
76
+ WordPress 3.0+
77
+ PHP 5+
78
+
79
+ = Feedback =
80
+
81
+ We would like to receive your feedback and suggestions. You may submit them at our [support desk](http://xyzscripts.com/members/support/ "XYZScripts Support").
shortcode-handler.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $wpdb;
3
+
4
+ add_shortcode('xyz-ips','xyz_ips_display_content');
5
+
6
+ function xyz_ips_display_content($xyz_snippet_name){
7
+ global $wpdb;
8
+
9
+ if(is_array($xyz_snippet_name)){
10
+ $snippet_name = $xyz_snippet_name['snippet'];
11
+
12
+ $query = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE title='$snippet_name'" );
13
+
14
+ if(count($query)>0){
15
+
16
+ foreach ($query as $sippetdetails){
17
+ if($sippetdetails->status==1){
18
+
19
+ if(is_numeric(ini_get('output_buffering'))){
20
+ $tmp=ob_get_contents();
21
+ ob_clean();
22
+ ob_start();
23
+ eval($sippetdetails->content);
24
+ $xyz_em_content = ob_get_contents();
25
+ ob_clean();
26
+ echo $tmp;
27
+ return $xyz_em_content;
28
+ }else{
29
+ eval($sippetdetails->content);
30
+ }
31
+
32
+
33
+
34
+ }else{
35
+ return '';
36
+ }
37
+ break;
38
+ }
39
+
40
+ }else{
41
+
42
+ return "<div style='padding:20px; font-size:16px; color:#FA5A6A; width:93%;text-align:center;background:lightyellow;border:1px solid #3FAFE3; margin:20px 0 20px 0'>
43
+
44
+ Please use a valid short code to call snippet.
45
+
46
+
47
+ </div>";
48
+
49
+ }
50
+
51
+ }
52
+ }
53
+
54
+
55
+ add_filter('widget_text', 'do_shortcode');
56
+
57
+
58
+
widget.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * XYZScripts Insert PHP Snippet Widget Class
5
+ */
6
+
7
+ ////*****************************Sidebar Widget**********************************////
8
+
9
+ class Xyz_Insert_Php_Widget extends WP_Widget {
10
+
11
+
12
+ /** constructor -- name this the same as the class above */
13
+ function Xyz_Insert_Php_Widget() {
14
+ parent::WP_Widget(false, $name = 'Insert PHP Snippet');
15
+ }
16
+
17
+ /** @see WP_Widget::widget -- do not rename this */
18
+ function widget($args, $instance) {
19
+ extract( $args );
20
+ global $wpdb;
21
+ $title = apply_filters('widget_title', $instance['title']);
22
+ $xyz_ips_id = $instance['message'];
23
+
24
+ $entries = $wpdb->get_results( "SELECT content FROM ".$wpdb->prefix."xyz_ips_short_code WHERE id='$xyz_ips_id'" );
25
+
26
+ $entry = $entries[0];
27
+
28
+ echo $before_widget;
29
+ if ( $title )
30
+ echo $before_title . $title . $after_title;
31
+ eval($entry->content);
32
+
33
+ echo $after_widget;
34
+
35
+ }
36
+
37
+ /** @see WP_Widget::update -- do not rename this */
38
+ function update($new_instance, $old_instance) {
39
+ $instance = $old_instance;
40
+ $instance['title'] = strip_tags($new_instance['title']);
41
+ $instance['message'] = strip_tags($new_instance['message']);
42
+ return $instance;
43
+ }
44
+
45
+ /** @see WP_Widget::form -- do not rename this */
46
+ function form($instance) {
47
+ global $wpdb;
48
+ $entries = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status='1' ORDER BY id DESC" );
49
+
50
+
51
+ if(isset($instance['title'])){
52
+ $title = esc_attr($instance['title']);
53
+ }else{
54
+ $title = '';
55
+ }
56
+
57
+ if(isset($instance['message'])){
58
+ $message = esc_attr($instance['message']);
59
+ }else{
60
+ $message = '';
61
+ }
62
+
63
+ ?>
64
+ <p>
65
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
66
+ <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; ?>" />
67
+ </p>
68
+ <p>
69
+ <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Choose Snippet :'); ?></label>
70
+
71
+ <!-- <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; ?>" />-->
72
+ <select name="<?php echo $this->get_field_name('message'); ?>">
73
+ <?php
74
+ if( count($entries)>0 ) {
75
+ $count=1;
76
+ $class = '';
77
+ foreach( $entries as $entry ) {
78
+ ?>
79
+ <option value="<?php echo $entry->id;?>" <?php if($message==$entry->id)echo "selected"; ?>><?php echo $entry->title;?></option>
80
+ <?php
81
+ }
82
+ }
83
+ ?>
84
+ </select>
85
+ </p>
86
+ <?php
87
+ }
88
+
89
+
90
+ } // end class Xyz_Insert_Php_Widget
91
+ add_action('widgets_init', create_function('', 'return register_widget("Xyz_Insert_Php_Widget");'));
92
+ ?>
xyz-functions.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!function_exists('xyz_ips_plugin_get_version'))
4
+ {
5
+ function xyz_ips_plugin_get_version()
6
+ {
7
+ if ( ! function_exists( 'get_plugins' ) )
8
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
9
+ $plugin_folder = get_plugins( '/' . plugin_basename( dirname( XYZ_INSERT_PHP_PLUGIN_FILE ) ) );
10
+ // print_r($plugin_folder);
11
+ return $plugin_folder['insert-php-code-snippet.php']['Version'];
12
+ }
13
+ }
14
+
15
+ if(!function_exists('xyz_trim_deep'))
16
+ {
17
+
18
+ function xyz_trim_deep($value) {
19
+ if ( is_array($value) ) {
20
+ $value = array_map('xyz_trim_deep', $value);
21
+ } elseif ( is_object($value) ) {
22
+ $vars = get_object_vars( $value );
23
+ foreach ($vars as $key=>$data) {
24
+ $value->{$key} = xyz_trim_deep( $data );
25
+ }
26
+ } else {
27
+ $value = trim($value);
28
+ }
29
+
30
+ return $value;
31
+ }
32
+
33
+ }
34
+
35
+
36
+ if(!function_exists('xyz_ips_links')){
37
+ function xyz_ips_links($links, $file) {
38
+ $base = plugin_basename(XYZ_INSERT_PHP_PLUGIN_FILE);
39
+ if ($file == $base) {
40
+
41
+ $links[] = '<a href="http://xyzscripts.com/support/" class="xyz_support" title="Support"></a>';
42
+ $links[] = '<a href="http://twitter.com/xyzscripts" class="xyz_twitt" title="Follow us on twitter"></a>';
43
+ $links[] = '<a href="https://www.facebook.com/xyzscripts" class="xyz_fbook" title="Facebook"></a>';
44
+ $links[] = '<a href="https://plus.google.com/101215320403235276710/" class="xyz_gplus" title="+1"></a>';
45
+ }
46
+ return $links;
47
+ }
48
+ }
49
+ add_filter( 'plugin_row_meta','xyz_ips_links',10,2);
50
+
51
+ ?>