My Custom Functions - Version 2.3

Version Description

  • Added function to check for duplicate function names. Compares the names of all functions (internal, user).
  • Added function for automatic remove the message about successful saving after 3 seconds.
  • Removed the default message about successful saving.
  • The function of user code cleaning modified.
  • File js-functions.js renamed to functions.js.
  • Removed my personal ad about freelance.
Download this release

Release Info

Developer Arthur Gareginyan
Plugin Icon 128x128 My Custom Functions
Version 2.3
Comparing to
See all releases

Code changes from version 2.2 to 2.3

LICENSE.txt CHANGED
File without changes
inc/codemirror/LICENSE CHANGED
File without changes
inc/codemirror/README.md CHANGED
File without changes
inc/codemirror/codemirror.css CHANGED
File without changes
inc/{js-functions.js → functions.js} RENAMED
@@ -1,12 +1,14 @@
1
  /*
2
  * My Custom Functions
3
  * JS functions
4
- * @since 2.0
5
  * @agareginyan
6
  */
7
 
8
 
9
  (function(){
 
 
10
  jQuery(document).ready(function($) {
11
 
12
  // Find all textareas on page
@@ -26,5 +28,13 @@
26
  editor.refresh();
27
  },1);
28
  });
 
 
 
 
 
 
 
29
  });
 
30
  }());
1
  /*
2
  * My Custom Functions
3
  * JS functions
4
+ * @since 2.3
5
  * @agareginyan
6
  */
7
 
8
 
9
  (function(){
10
+ "use strict";
11
+
12
  jQuery(document).ready(function($) {
13
 
14
  // Find all textareas on page
28
  editor.refresh();
29
  },1);
30
  });
31
+
32
+ // Remove the message about successful saving
33
+ if (".updated") {
34
+ setTimeout(function() {
35
+ $(".updated").fadeOut();
36
+ }, 3000);
37
+ }
38
  });
39
+
40
  }());
inc/images/thanks.png CHANGED
Binary file
inc/settings_page.php CHANGED
@@ -10,7 +10,7 @@ defined('ABSPATH') or die("Restricted access!");
10
  /**
11
  * Render Settings Page
12
  *
13
- * @since 2.2
14
  */
15
  function MCFunctions_render_submenu_page() {
16
 
@@ -43,7 +43,7 @@ function MCFunctions_render_submenu_page() {
43
  <?php _e( 'My Custom Functions', 'my-custom-functions' ); ?>
44
  <br/>
45
  <span>
46
- <?php _e( 'by <a href="http://www.arthurgareginyan.com" target="_blank">Arthur "Berserkr" Gareginyan</a>', 'my-custom-functions' ); ?>
47
  <span/>
48
  </h2>
49
 
@@ -70,8 +70,8 @@ function MCFunctions_render_submenu_page() {
70
  <div id="help" class="postbox">
71
  <h3 class="title"><?php _e( 'Help', 'my-custom-functions' ); ?></h3>
72
  <div class="inside">
73
- <p><?php _e( 'If you want more options then tell me and I will be happy to add it.', 'my-custom-functions' ); ?></p>
74
- <p><a href="mailto:arthurgareginyan@gmail.com">arthurgareginyan@gmail.com</a></p>
75
  </div>
76
  </div>
77
 
@@ -87,16 +87,6 @@ function MCFunctions_render_submenu_page() {
87
  </div>
88
  </div>
89
 
90
- <div id="freelance" class="postbox">
91
- <h3 class="title"><?php _e( 'Freelance', 'my-custom-functions' ) ?></h3>
92
- <div class="inside">
93
- <img src="<?php echo plugins_url('images/author.png', __FILE__); ?>">
94
- <p><?php _e( 'Hello, my name is Arthur and I\'m a freelance web designer and developer.', 'my-custom-functions' ) ?></p>
95
- <p><?php _e( 'Share your thoughts with me. You may have a brilliant idea in your mind and I can make it happen, so let’s get started!', 'my-custom-functions' ) ?></p>
96
- <p><a href="http://www.arthurgareginyan.com/" target="_blank">www.arthurgareginyan.com</a></p>
97
- </div>
98
- </div>
99
-
100
  </div>
101
  </div>
102
  <!-- END-SIDEBAR -->
@@ -136,4 +126,4 @@ function MCFunctions_render_submenu_page() {
136
 
137
  </div>
138
  <?php
139
- }
10
  /**
11
  * Render Settings Page
12
  *
13
+ * @since 2.3
14
  */
15
  function MCFunctions_render_submenu_page() {
16
 
43
  <?php _e( 'My Custom Functions', 'my-custom-functions' ); ?>
44
  <br/>
45
  <span>
46
+ <?php _e( 'by <a href="http://www.arthurgareginyan.com" target="_blank">Arthur Gareginyan</a>', 'my-custom-functions' ); ?>
47
  <span/>
48
  </h2>
49
 
70
  <div id="help" class="postbox">
71
  <h3 class="title"><?php _e( 'Help', 'my-custom-functions' ); ?></h3>
72
  <div class="inside">
73
+ <p><?php _e( 'Got something to say? Need help?', 'my-custom-functions' ); ?></p>
74
+ <p><a href="mailto:arthurgareginyan@gmail.com?subject=My Custom Functions">arthurgareginyan@gmail.com</a></p>
75
  </div>
76
  </div>
77
 
87
  </div>
88
  </div>
89
 
 
 
 
 
 
 
 
 
 
 
90
  </div>
91
  </div>
92
  <!-- END-SIDEBAR -->
126
 
127
  </div>
128
  <?php
129
+ }
inc/style.css CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
  * My Custom Functions
3
  * Style sheet for plugin's page
4
- * @since 2.1
5
  * @agareginyan
6
  */
7
 
@@ -10,6 +10,7 @@
10
  text-align: center;
11
  }
12
 
 
13
  h2 {
14
  text-align: center;
15
  font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
@@ -33,24 +34,12 @@ h3.title {
33
  border-bottom: 1px solid #eee;
34
  }
35
 
36
- .inner-sidebar h3.title {
37
- text-align: center;
38
- }
39
-
40
- td.help-text {
41
- font-style: italic;
42
- font-size: 12px !important;
43
- float: left;
44
- clear: left;
45
- color: #797979;
46
- line-height: 15px;
47
- padding-top: 0px !important;
48
- }
49
-
50
- .postbox a {
51
- text-decoration: none;
52
  }
53
 
 
54
  .CodeMirror {
55
  height: 100% !important;
56
  border: 1px solid grey;
@@ -58,26 +47,31 @@ td.help-text {
58
  margin-right: 5px;
59
  }
60
 
 
61
  #side-sortables {
62
  position: relative;
63
  }
64
 
65
- #about {
66
  text-align: center;
67
  }
68
 
69
- #using {
70
- text-align: center;
71
  }
72
 
73
- #help {
 
 
 
74
  text-align: center;
75
  }
76
 
77
- #donate {
78
- text-align: center;
79
  }
80
 
81
- #freelance {
82
- text-align: center;
83
- }
 
1
  /*
2
  * My Custom Functions
3
  * Style sheet for plugin's page
4
+ * @since 2.3
5
  * @agareginyan
6
  */
7
 
10
  text-align: center;
11
  }
12
 
13
+ /* Titles */
14
  h2 {
15
  text-align: center;
16
  font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
34
  border-bottom: 1px solid #eee;
35
  }
36
 
37
+ /* Messages */
38
+ #setting-error-settings_updated {
39
+ display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
+ /* CodeMirror Editor */
43
  .CodeMirror {
44
  height: 100% !important;
45
  border: 1px solid grey;
47
  margin-right: 5px;
48
  }
49
 
50
+ /* Sidebar */
51
  #side-sortables {
52
  position: relative;
53
  }
54
 
55
+ .inner-sidebar h3.title {
56
  text-align: center;
57
  }
58
 
59
+ .postbox a {
60
+ text-decoration: none;
61
  }
62
 
63
+ #about,
64
+ #using,
65
+ #help,
66
+ #donate {
67
  text-align: center;
68
  }
69
 
70
+ #help p {
71
+ margin: 0;
72
  }
73
 
74
+ #donate img,
75
+ #donate p {
76
+ margin-top: 5px;
77
+ }
languages/my-custom-functions-ru_RU.mo CHANGED
Binary file
languages/my-custom-functions-ru_RU.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: My Custom Functions\n"
4
- "POT-Creation-Date: 2016-04-08 14:08+0300\n"
5
- "PO-Revision-Date: 2016-04-08 14:08+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: ru\n"
@@ -42,10 +42,10 @@ msgstr ""
42
  #: inc/settings_page.php:46
43
  msgid ""
44
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
45
- "\"Berserkr\" Gareginyan</a>"
46
  msgstr ""
47
- "от <a href=“http://www.arthurgareginyan.com target=“_blank”>Артур "
48
- "“Berserkr” Гарегинян</a>"
49
 
50
  #: inc/settings_page.php:57
51
  msgid "About"
@@ -76,10 +76,8 @@ msgid "Help"
76
  msgstr "Помощь"
77
 
78
  #: inc/settings_page.php:73
79
- msgid "If you want more options then tell me and I will be happy to add it."
80
- msgstr ""
81
- "Если вы хотите больше опций, то скажите мне об этом и я буду счастлив "
82
- "добавить их."
83
 
84
  #: inc/settings_page.php:79
85
  msgid "Donate"
@@ -97,28 +95,11 @@ msgstr ""
97
  msgid "Thanks for your support!"
98
  msgstr "Спасибо за вашу поддержку!"
99
 
100
- #: inc/settings_page.php:91
101
- msgid "Freelance"
102
- msgstr "Фриланс"
103
-
104
- #: inc/settings_page.php:94
105
- msgid ""
106
- "Hello, my name is Arthur and I'm a freelance web designer and developer."
107
- msgstr "Привет, меня зовут Артур и Я внештатный веб-дизайнер и разработчик."
108
-
109
- #: inc/settings_page.php:95
110
- msgid ""
111
- "Share your thoughts with me. You may have a brilliant idea in your mind and "
112
- "I can make it happen, so let’s get started!"
113
- msgstr ""
114
- "Поделитесь со мной своими мыслями. У вас может быть блестящая идея в уме, а "
115
- "я могу сделать её явью, так что давайте начнём!"
116
-
117
- #: inc/settings_page.php:119
118
  msgid "Functions"
119
  msgstr "Функции"
120
 
121
- #: inc/settings_page.php:126
122
  msgid "Save Changes"
123
  msgstr "Сохранить изменения"
124
 
@@ -151,6 +132,32 @@ msgstr "Артур Гарегинян"
151
  msgid "http://www.arthurgareginyan.com"
152
  msgstr ""
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  #~ msgid "Arthur \"Berserkr\" Gareginyan"
155
  #~ msgstr "Артур “Берсерк” Гарегинян"
156
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: My Custom Functions\n"
4
+ "POT-Creation-Date: 2016-07-20 12:12+0300\n"
5
+ "PO-Revision-Date: 2016-07-20 12:13+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: ru\n"
42
  #: inc/settings_page.php:46
43
  msgid ""
44
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
45
+ "Gareginyan</a>"
46
  msgstr ""
47
+ "от <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Артур "
48
+ "Гарегинян</a>"
49
 
50
  #: inc/settings_page.php:57
51
  msgid "About"
76
  msgstr "Помощь"
77
 
78
  #: inc/settings_page.php:73
79
+ msgid "Got something to say? Need help?"
80
+ msgstr "Есть что сказать? Нужна помощь?"
 
 
81
 
82
  #: inc/settings_page.php:79
83
  msgid "Donate"
95
  msgid "Thanks for your support!"
96
  msgstr "Спасибо за вашу поддержку!"
97
 
98
+ #: inc/settings_page.php:109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  msgid "Functions"
100
  msgstr "Функции"
101
 
102
+ #: inc/settings_page.php:116
103
  msgid "Save Changes"
104
  msgstr "Сохранить изменения"
105
 
132
  msgid "http://www.arthurgareginyan.com"
133
  msgstr ""
134
 
135
+ #~ msgid ""
136
+ #~ "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
137
+ #~ "\"Berserkr\" Gareginyan</a>"
138
+ #~ msgstr ""
139
+ #~ "от <a href=“http://www.arthurgareginyan.com” target=“_blank”>Артур "
140
+ #~ "“Berserkr” Гарегинян</a>"
141
+
142
+ #~ msgid "If you want more options then tell me and I will be happy to add it."
143
+ #~ msgstr ""
144
+ #~ "Если вы хотите больше опций, то скажите мне об этом и я буду счастлив "
145
+ #~ "добавить их."
146
+
147
+ #~ msgid "Freelance"
148
+ #~ msgstr "Фриланс"
149
+
150
+ #~ msgid ""
151
+ #~ "Hello, my name is Arthur and I'm a freelance web designer and developer."
152
+ #~ msgstr "Привет, меня зовут Артур и Я внештатный веб-дизайнер и разработчик."
153
+
154
+ #~ msgid ""
155
+ #~ "Share your thoughts with me. You may have a brilliant idea in your mind "
156
+ #~ "and I can make it happen, so let’s get started!"
157
+ #~ msgstr ""
158
+ #~ "Поделитесь со мной своими мыслями. У вас может быть блестящая идея в уме, "
159
+ #~ "а я могу сделать её явью, так что давайте начнём!"
160
+
161
  #~ msgid "Arthur \"Berserkr\" Gareginyan"
162
  #~ msgstr "Артур “Берсерк” Гарегинян"
163
 
languages/my-custom-functions.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: My Custom Functions\n"
6
- "POT-Creation-Date: 2016-04-08 14:08+0300\n"
7
  "PO-Revision-Date: 2015-08-30 16:22+0300\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
@@ -40,7 +40,7 @@ msgstr ""
40
  #: inc/settings_page.php:46
41
  msgid ""
42
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
43
- "\"Berserkr\" Gareginyan</a>"
44
  msgstr ""
45
 
46
  #: inc/settings_page.php:57
@@ -68,7 +68,7 @@ msgid "Help"
68
  msgstr ""
69
 
70
  #: inc/settings_page.php:73
71
- msgid "If you want more options then tell me and I will be happy to add it."
72
  msgstr ""
73
 
74
  #: inc/settings_page.php:79
@@ -85,26 +85,11 @@ msgstr ""
85
  msgid "Thanks for your support!"
86
  msgstr ""
87
 
88
- #: inc/settings_page.php:91
89
- msgid "Freelance"
90
- msgstr ""
91
-
92
- #: inc/settings_page.php:94
93
- msgid ""
94
- "Hello, my name is Arthur and I'm a freelance web designer and developer."
95
- msgstr ""
96
-
97
- #: inc/settings_page.php:95
98
- msgid ""
99
- "Share your thoughts with me. You may have a brilliant idea in your mind and "
100
- "I can make it happen, so let’s get started!"
101
- msgstr ""
102
-
103
- #: inc/settings_page.php:119
104
  msgid "Functions"
105
  msgstr ""
106
 
107
- #: inc/settings_page.php:126
108
  msgid "Save Changes"
109
  msgstr ""
110
 
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: My Custom Functions\n"
6
+ "POT-Creation-Date: 2016-07-20 12:12+0300\n"
7
  "PO-Revision-Date: 2015-08-30 16:22+0300\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
40
  #: inc/settings_page.php:46
41
  msgid ""
42
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
43
+ "Gareginyan</a>"
44
  msgstr ""
45
 
46
  #: inc/settings_page.php:57
68
  msgstr ""
69
 
70
  #: inc/settings_page.php:73
71
+ msgid "Got something to say? Need help?"
72
  msgstr ""
73
 
74
  #: inc/settings_page.php:79
85
  msgid "Thanks for your support!"
86
  msgstr ""
87
 
88
+ #: inc/settings_page.php:109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  msgid "Functions"
90
  msgstr ""
91
 
92
+ #: inc/settings_page.php:116
93
  msgid "Save Changes"
94
  msgstr ""
95
 
my-custom-functions.php CHANGED
@@ -5,12 +5,12 @@
5
  * Description: Easily and safely add your own functions, snippets or any custom codes directly out of your WordPress Dashboard without need of an external editor.
6
  * Author: Arthur Gareginyan
7
  * Author URI: http://www.arthurgareginyan.com
8
- * Version: 2.2
9
  * License: GPL3
10
  * Text Domain: my-custom-functions
11
  * Domain Path: /languages/
12
  *
13
- * Copyright 2014-2016 Arthur "Berserkr" Gareginyan (email : arthurgareginyan@gmail.com)
14
  *
15
  * This file is part of "My Custom Functions".
16
  *
@@ -37,7 +37,7 @@
37
  defined('ABSPATH') or die("Restricted access!");
38
 
39
  /**
40
- * Plugin constants
41
  *
42
  * @since 2.0
43
  */
@@ -97,14 +97,14 @@ require_once( MCFUNC_PATH . 'inc/settings_page.php' );
97
  */
98
  function MCFunctions_register_settings() {
99
  register_setting( 'anarcho_cfunctions_settings_group', 'anarcho_cfunctions_settings' );
100
- register_setting( 'anarcho_cfunctions_settings_group', 'anarcho_cfunctions_pro_error' );
101
  }
102
  add_action( 'admin_init', 'MCFunctions_register_settings' );
103
 
104
  /**
105
- * Enqueue the CodeMirror scripts and style sheet for setting's page
106
  *
107
- * @since 2.0
108
  */
109
  function MCFunctions_enqueue_codemirror_scripts($hook) {
110
 
@@ -118,7 +118,7 @@ function MCFunctions_enqueue_codemirror_scripts($hook) {
118
  wp_enqueue_style('codemirror_style', MCFUNC_URL . 'inc/codemirror/codemirror.css');
119
 
120
  // JS functions
121
- wp_enqueue_script('js-functions', MCFUNC_URL . 'inc/js-functions.js', array(), false, true);
122
 
123
  // Style sheet
124
  wp_enqueue_style('styles', MCFUNC_URL . 'inc/style.css');
@@ -126,34 +126,90 @@ function MCFunctions_enqueue_codemirror_scripts($hook) {
126
  add_action( 'admin_enqueue_scripts', 'MCFunctions_enqueue_codemirror_scripts' );
127
 
128
  /**
129
- * Execute My Custom Functions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  *
131
- * @since 1.4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  */
133
  function MCFunctions_exec() {
134
- // Read from BD
135
- $options = get_option( 'anarcho_cfunctions_settings' );
136
- $content = $options['anarcho_cfunctions-content'];
137
-
138
- // Cleaning
139
- $content = trim( $content );
140
- $content = trim( $content, '<?php' );
141
-
142
- // Parsing and execute safe
143
- if ( !empty($content) ) {
144
- if( false === @eval( $content ) ) {
145
- //ERROR
146
- update_option( 'anarcho_cfunctions_error', '1' );
147
- } else {
148
- // Reset error value
149
- update_option( 'anarcho_cfunctions_error', '0' );
 
 
 
 
 
150
  }
151
- }
152
  }
153
  MCFunctions_exec();
154
 
155
  /**
156
- * Delete Options on Uninstall
157
  *
158
  * @since 0.1
159
  */
5
  * Description: Easily and safely add your own functions, snippets or any custom codes directly out of your WordPress Dashboard without need of an external editor.
6
  * Author: Arthur Gareginyan
7
  * Author URI: http://www.arthurgareginyan.com
8
+ * Version: 2.3
9
  * License: GPL3
10
  * Text Domain: my-custom-functions
11
  * Domain Path: /languages/
12
  *
13
+ * Copyright 2014-2016 Arthur Gareginyan (email : arthurgareginyan@gmail.com)
14
  *
15
  * This file is part of "My Custom Functions".
16
  *
37
  defined('ABSPATH') or die("Restricted access!");
38
 
39
  /**
40
+ * Define constants
41
  *
42
  * @since 2.0
43
  */
97
  */
98
  function MCFunctions_register_settings() {
99
  register_setting( 'anarcho_cfunctions_settings_group', 'anarcho_cfunctions_settings' );
100
+ register_setting( 'anarcho_cfunctions_settings_group', 'anarcho_cfunctions_error' );
101
  }
102
  add_action( 'admin_init', 'MCFunctions_register_settings' );
103
 
104
  /**
105
+ * Enqueue the CodeMirror scripts and style sheet for settings page
106
  *
107
+ * @since 2.3
108
  */
109
  function MCFunctions_enqueue_codemirror_scripts($hook) {
110
 
118
  wp_enqueue_style('codemirror_style', MCFUNC_URL . 'inc/codemirror/codemirror.css');
119
 
120
  // JS functions
121
+ wp_enqueue_script('js-functions', MCFUNC_URL . 'inc/functions.js', array(), false, true);
122
 
123
  // Style sheet
124
  wp_enqueue_style('styles', MCFUNC_URL . 'inc/style.css');
126
  add_action( 'admin_enqueue_scripts', 'MCFunctions_enqueue_codemirror_scripts' );
127
 
128
  /**
129
+ * Prepare the user entered code for execution
130
+ *
131
+ * @since 2.3
132
+ */
133
+ function MCFunctions_prepare() {
134
+
135
+ // Read from DB
136
+ $options = get_option( 'anarcho_cfunctions_settings' );
137
+ $content = $options['anarcho_cfunctions-content'];
138
+
139
+ // Cleaning
140
+ $content = trim( $content );
141
+ $content = ltrim( $content, '<?php' );
142
+ $content = rtrim( $content, '?>' );
143
+
144
+ // Return prepared code
145
+ return $content;
146
+ }
147
+
148
+ /**
149
+ * Check the user entered code for duplicate names of functions
150
  *
151
+ * @since 2.3
152
+ */
153
+ function MCFunctions_duplicates() {
154
+
155
+ // Find names of user entered functions and check for duplicates
156
+ $user_func = MCFunctions_prepare();
157
+ preg_match_all('/function[\s\n]+(\S+)[\s\n]*\(/i', $user_func, $user_func_names);
158
+ $user_func_a = count( $user_func_names[1] );
159
+ $user_func_b = count( array_unique( $user_func_names[1] ) );
160
+
161
+ // Find all names of declared user functions and mutch with names of user entered functions
162
+ $declared_func = get_defined_functions();
163
+ $declared_func_user = array_intersect( $user_func_names[1], $declared_func['user'] );
164
+ $declared_func_internal = array_intersect( $user_func_names[1], $declared_func['internal'] );
165
+
166
+ // Update error status
167
+ if ( $user_func_a != $user_func_b OR count( $declared_func_user ) > 0 OR count( $declared_func_internal ) > 0 ) {
168
+ update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
169
+ $duplicates_status = '1';
170
+ } else {
171
+ update_option( 'anarcho_cfunctions_error', '0' ); // RESET ERROR VALUE
172
+ $duplicates_status = '0';
173
+ }
174
+
175
+ // Return error status
176
+ return $duplicates_status;
177
+ }
178
+
179
+ /**
180
+ * Execute the user code
181
+ *
182
+ * @since 2.3
183
  */
184
  function MCFunctions_exec() {
185
+
186
+ // Get the error status
187
+ $error_status = get_option( 'anarcho_cfunctions_error' );
188
+ $duplicates_status = MCFunctions_duplicates();
189
+
190
+ if ( $error_status > 0 OR $duplicates_status > 0 ) {
191
+ return; // EXIT
192
+ } else {
193
+
194
+ // Get the user entered functions by calling the "prepare" function
195
+ $content = MCFunctions_prepare();
196
+
197
+ if ( !empty($content) AND $content != ' ' ) {
198
+
199
+ // Parsing and execute by Eval
200
+ if( false === @eval( $content ) ) {
201
+ update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
202
+ return; // EXIT
203
+ } else {
204
+ update_option( 'anarcho_cfunctions_error', '0' ); // RESET ERROR VALUE
205
+ }
206
  }
207
+ }
208
  }
209
  MCFunctions_exec();
210
 
211
  /**
212
+ * Delete options on uninstall
213
  *
214
  * @since 0.1
215
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: code, php, function, snippet, custom, execute, edit, editing, editor, func
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8A88KC7TFF6CS
5
  Requires at least: 3.9
6
  Tested up to: 4.5
7
- Stable tag: 2.1
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -12,32 +12,24 @@ Easily and safely add your own functions, snippets or any custom codes directly
12
 
13
 
14
  == Description ==
15
- An easy to use WordPress plugin that lets you easily and safely add your own functions, snippets or any custom codes for execution in WordPress environment directly out of your WordPress Dashboard without any need of an external editor.
16
-
17
- It’s purpose is to provide a familiar experience to WordPress users. No need any more editing the functions.php file of your theme. Just add your code in the field on the page and this plugin will do the rest for you.
18
-
19
- No any more "Fatal error". These codes will run safely and will not generate fatal errors, so your website won't break if you make a typo in your code.
20
-
21
- And your website will keep on working, no matter how many times you upgrade or switch your theme.
22
-
23
- This is a simple and perfect tool to use as your site's functionality plugin.
24
 
25
  = Features =
26
 
27
  **Current features:**
28
 
29
- * Safety execution code (Checks the entered code for fatal errors)
30
  * Syntax highlighting (by CodeMirror)
31
  * Line numbering (by CodeMirror)
32
- * Input areas allow for tab indentation
33
  * Ready for translation (.pot file included)
34
  * Russian translation
35
- * CodeMirror scripts are combined and minified
36
 
37
- **Coming soon:**
 
 
 
38
 
39
- * Trigger to temporary disable the custom code
40
- * Backuping the custom code to a file
41
 
42
  >**Contribution**
43
  >
@@ -87,8 +79,17 @@ A. Absolutely not. This plugin is added/configured entirely from the website's A
87
  = Q. It's not working. What could be wrong? =
88
  A. As with every plugin, it's possible that things don't work. The most common reason for this is that the plugin has a conflict with another plugin you're using. It's impossible to tell what could be wrong exactly, but if you post a support request in the plugin's support forum on WordPress.org, I'd be happy to give it a look and try to help out. Please include as much information as possible, including a link to your website where the problem can be seen.
89
 
 
 
 
 
 
 
 
 
 
90
  = Q. What to do if this plugin caused the white screen? =
91
- A. This plugin is not perfect, so there are times when the entered custom code causes the error and white screen. If this happened with you then do the following.
92
 
93
  Your code stored in the Database of your web-site. For getting your code, you can go to the `Database` —> Table "`wp_options`" —> Option "`anarcho_cfunctions_settings`" —> "`option_value`".
94
 
@@ -125,7 +126,7 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
125
 
126
  **Credits**
127
 
128
- [CodeMirror](https://codemirror.net/) is an open-source project shared under an [MIT license](https://codemirror.net/LICENSE).
129
 
130
  **Links**
131
 
@@ -134,6 +135,13 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
134
 
135
 
136
  == Changelog ==
 
 
 
 
 
 
 
137
  = 2.2 =
138
  * Added Chinese (Taiwan) translation. (Thanks Gordon Yu)
139
  * Text domain changed to "my-custom-functions".
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8A88KC7TFF6CS
5
  Requires at least: 3.9
6
  Tested up to: 4.5
7
+ Stable tag: 2.2
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
12
 
13
 
14
  == Description ==
15
+ An easy to use WordPress plugin that gives you the ability to easily and safely add your own functions, snippets or any custom codes for execution in WordPress environment directly out of your WordPress Dashboard and without any need of an external editor.
16
+
 
 
 
 
 
 
 
17
 
18
  = Features =
19
 
20
  **Current features:**
21
 
22
+ * Checks the entered code for fatal errors (simple checks)
23
  * Syntax highlighting (by CodeMirror)
24
  * Line numbering (by CodeMirror)
 
25
  * Ready for translation (.pot file included)
26
  * Russian translation
 
27
 
28
+ **Coming soon:**
29
+ * Reload the settings page at same position after pushing the save button
30
+ * Multisite network support
31
+ * Easier disable/enable option for WSOD
32
 
 
 
33
 
34
  >**Contribution**
35
  >
79
  = Q. It's not working. What could be wrong? =
80
  A. As with every plugin, it's possible that things don't work. The most common reason for this is that the plugin has a conflict with another plugin you're using. It's impossible to tell what could be wrong exactly, but if you post a support request in the plugin's support forum on WordPress.org, I'd be happy to give it a look and try to help out. Please include as much information as possible, including a link to your website where the problem can be seen.
81
 
82
+ = Q. On the plugin settings page, an error message appears. What could be wrong? =
83
+
84
+ A. Here are a few of the most likely causes of the error message:
85
+
86
+ 1. You make a syntax error in the code that you have entered. Check the syntax of your code and try again.
87
+ 2. You entered two functions with the same name. Use a unique names for your functions.
88
+ 3. You have entered function with a name that is already occupied by another function. Use a unique name for your function.
89
+ 4. You are trying to overwrite an existing function (of WordPress, theme, or plugin). Instead, use filters and hooks.
90
+
91
  = Q. What to do if this plugin caused the white screen? =
92
+ A. This plugin is not perfect, so there are times when the entered custom code causes the error and white screen (WSOD). If this happened with you then do the following.
93
 
94
  Your code stored in the Database of your web-site. For getting your code, you can go to the `Database` —> Table "`wp_options`" —> Option "`anarcho_cfunctions_settings`" —> "`option_value`".
95
 
126
 
127
  **Credits**
128
 
129
+ [CodeMirror](https://codemirror.net/) is an open-source project shared under a [MIT license](https://codemirror.net/LICENSE).
130
 
131
  **Links**
132
 
135
 
136
 
137
  == Changelog ==
138
+ = 2.3 =
139
+ * Added function to check for duplicate function names. Compares the names of all functions (internal, user).
140
+ * Added function for automatic remove the message about successful saving after 3 seconds.
141
+ * Removed the default message about successful saving.
142
+ * The function of user code cleaning modified.
143
+ * File js-functions.js renamed to functions.js.
144
+ * Removed my personal ad about freelance.
145
  = 2.2 =
146
  * Added Chinese (Taiwan) translation. (Thanks Gordon Yu)
147
  * Text domain changed to "my-custom-functions".