My Custom Functions - Version 2.5

Version Description

  • Added active-line addon to CodeMirror.
  • Extra update_option() removed from the _duplicates function.
  • The _exec function optimized.
  • CSS class "slider" renamed to "trigger".
  • Styles of settings page optimized for mobile devices.
  • The styles.css file better commented.
  • The enqueue_codemirror_scripts function renamed to mcstylesload_scripts.
Download this release

Release Info

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

Code changes from version 2.4 to 2.5

inc/codemirror/addons/active-line.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Because sometimes you need to style the cursor's line.
5
+ //
6
+ // Adds an option 'styleActiveLine' which, when enabled, gives the
7
+ // active line's wrapping <div> the CSS class "CodeMirror-activeline",
8
+ // and gives its background <div> the class "CodeMirror-activeline-background".
9
+
10
+ (function(mod) {
11
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
12
+ mod(require("../../lib/codemirror"));
13
+ else if (typeof define == "function" && define.amd) // AMD
14
+ define(["../../lib/codemirror"], mod);
15
+ else // Plain browser env
16
+ mod(CodeMirror);
17
+ })(function(CodeMirror) {
18
+ "use strict";
19
+ var WRAP_CLASS = "CodeMirror-activeline";
20
+ var BACK_CLASS = "CodeMirror-activeline-background";
21
+ var GUTT_CLASS = "CodeMirror-activeline-gutter";
22
+
23
+ CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
24
+ var prev = old && old != CodeMirror.Init;
25
+ if (val && !prev) {
26
+ cm.state.activeLines = [];
27
+ updateActiveLines(cm, cm.listSelections());
28
+ cm.on("beforeSelectionChange", selectionChange);
29
+ } else if (!val && prev) {
30
+ cm.off("beforeSelectionChange", selectionChange);
31
+ clearActiveLines(cm);
32
+ delete cm.state.activeLines;
33
+ }
34
+ });
35
+
36
+ function clearActiveLines(cm) {
37
+ for (var i = 0; i < cm.state.activeLines.length; i++) {
38
+ cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
39
+ cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
40
+ cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
41
+ }
42
+ }
43
+
44
+ function sameArray(a, b) {
45
+ if (a.length != b.length) return false;
46
+ for (var i = 0; i < a.length; i++)
47
+ if (a[i] != b[i]) return false;
48
+ return true;
49
+ }
50
+
51
+ function updateActiveLines(cm, ranges) {
52
+ var active = [];
53
+ for (var i = 0; i < ranges.length; i++) {
54
+ var range = ranges[i];
55
+ if (!range.empty()) continue;
56
+ var line = cm.getLineHandleVisualStart(range.head.line);
57
+ if (active[active.length - 1] != line) active.push(line);
58
+ }
59
+ if (sameArray(cm.state.activeLines, active)) return;
60
+ cm.operation(function() {
61
+ clearActiveLines(cm);
62
+ for (var i = 0; i < active.length; i++) {
63
+ cm.addLineClass(active[i], "wrap", WRAP_CLASS);
64
+ cm.addLineClass(active[i], "background", BACK_CLASS);
65
+ cm.addLineClass(active[i], "gutter", GUTT_CLASS);
66
+ }
67
+ cm.state.activeLines = active;
68
+ });
69
+ }
70
+
71
+ function selectionChange(cm, sel) {
72
+ updateActiveLines(cm, sel.ranges);
73
+ }
74
+ });
inc/functions.js CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
  * My Custom Functions
3
  * JS functions
4
- * @since 2.3
5
  * @agareginyan
6
  */
7
 
@@ -20,7 +20,8 @@
20
  firstLineNumber: 1,
21
  matchBrackets: true,
22
  indentUnit: 4,
23
- mode: 'text/x-php'
 
24
  });
25
 
26
  // Refresh CodeMirror editor after 1 second
@@ -29,7 +30,7 @@
29
  },1);
30
  });
31
 
32
- // Remove the message about successful saving
33
  if (".updated") {
34
  setTimeout(function() {
35
  $(".updated").fadeOut();
@@ -37,4 +38,4 @@
37
  }
38
  });
39
 
40
- }());
1
  /*
2
  * My Custom Functions
3
  * JS functions
4
+ * @since 2.5
5
  * @agareginyan
6
  */
7
 
20
  firstLineNumber: 1,
21
  matchBrackets: true,
22
  indentUnit: 4,
23
+ mode: 'text/x-php',
24
+ styleActiveLine: true
25
  });
26
 
27
  // Refresh CodeMirror editor after 1 second
30
  },1);
31
  });
32
 
33
+ // Remove the "successful" message after 3 seconds
34
  if (".updated") {
35
  setTimeout(function() {
36
  $(".updated").fadeOut();
38
  }
39
  });
40
 
41
+ }());
inc/images/author.png DELETED
Binary file
inc/settings_page.php CHANGED
@@ -10,18 +10,20 @@ defined('ABSPATH') or die("Restricted access!");
10
  /**
11
  * Render Settings Page
12
  *
13
- * @since 2.4
14
  */
15
  function MCFunctions_render_submenu_page() {
16
 
17
- // Settings update message
18
- if ( isset( $_GET['settings-updated'] ) ) :
 
 
19
  ?>
20
  <div id="message" class="updated">
21
  <p><?php _e( 'Custom functions updated successfully.', 'my-custom-functions' ); ?></p>
22
  </div>
23
  <?php
24
- endif;
25
 
26
  // Error message
27
  $error = get_option( 'anarcho_cfunctions_error' );
@@ -56,7 +58,7 @@ function MCFunctions_render_submenu_page() {
56
  <div id="about" class="postbox">
57
  <h3 class="title"><?php _e( 'About', 'my-custom-functions' ) ?></a></h3>
58
  <div class="inside">
59
- <p><?php _e( 'This plugin allows you to easily and safely add your own functions, snippets or any custom code to your website.', 'my-custom-functions' ) ?></p>
60
  </div>
61
  </div>
62
 
@@ -107,8 +109,8 @@ function MCFunctions_render_submenu_page() {
107
  ?>
108
  <div class="postbox">
109
  <h3 class="title">
110
- <label for="anarcho_cfunctions_settings[anarcho_cfunctions-content]" ><?php _e( 'Functions', 'my-custom-functions' ) ?></label>
111
- <div class="slider">
112
  <input type="checkbox" name="anarcho_cfunctions_settings[enable]" id="anarcho_cfunctions_settings[enable]" <?php echo $enable; ?> >
113
  <label for="anarcho_cfunctions_settings[enable]"></label>
114
  </div>
10
  /**
11
  * Render Settings Page
12
  *
13
+ * @since 2.5
14
  */
15
  function MCFunctions_render_submenu_page() {
16
 
17
+ // After settings updated
18
+ if ( isset( $_GET['settings-updated'] ) ) {
19
+
20
+ // Successful message
21
  ?>
22
  <div id="message" class="updated">
23
  <p><?php _e( 'Custom functions updated successfully.', 'my-custom-functions' ); ?></p>
24
  </div>
25
  <?php
26
+ }
27
 
28
  // Error message
29
  $error = get_option( 'anarcho_cfunctions_error' );
58
  <div id="about" class="postbox">
59
  <h3 class="title"><?php _e( 'About', 'my-custom-functions' ) ?></a></h3>
60
  <div class="inside">
61
+ <p><?php _e( 'This plugin allows you to easily and safely add your custome functions (PHP code) to your website.', 'my-custom-functions' ) ?></p>
62
  </div>
63
  </div>
64
 
109
  ?>
110
  <div class="postbox">
111
  <h3 class="title">
112
+ <label for="anarcho_cfunctions_settings[anarcho_cfunctions-content]" ><?php _e( 'Functions (PHP code)', 'my-custom-functions' ) ?></label>
113
+ <div class="trigger">
114
  <input type="checkbox" name="anarcho_cfunctions_settings[enable]" id="anarcho_cfunctions_settings[enable]" <?php echo $enable; ?> >
115
  <label for="anarcho_cfunctions_settings[enable]"></label>
116
  </div>
inc/style.css CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
  * My Custom Functions
3
  * Style sheet for plugin's page
4
- * @since 2.4
5
  * @agareginyan
6
  */
7
 
@@ -10,7 +10,8 @@
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;
@@ -32,23 +33,25 @@ h2 span a {
32
  h3.title {
33
  font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
34
  border-bottom: 1px solid #eee;
35
- height: 25px;
36
  }
37
 
38
- /* Messages */
 
39
  #setting-error-settings_updated {
40
  display: none;
41
  }
42
 
43
- /* CodeMirror Editor */
 
44
  .CodeMirror {
45
  height: 100% !important;
46
- border: 1px solid grey;
47
  margin-left: 5px;
48
  margin-right: 5px;
49
  }
50
 
51
- /* Sidebar */
 
52
  #side-sortables {
53
  position: relative;
54
  }
@@ -77,9 +80,20 @@ h3.title {
77
  margin-top: 5px;
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
80
  /* On/Off Trigger
81
  -------------------------------------------------------------- */
82
- .slider {
83
  margin-left: auto;
84
  margin-right: 0;
85
  margin-top: -20px;
@@ -96,7 +110,7 @@ h3.title {
96
  box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
97
  }
98
 
99
- .slider:after {
100
  content: 'ON';
101
  margin-top: -3px;
102
  font: 12px/26px Arial, sans-serif;
@@ -108,7 +122,7 @@ h3.title {
108
  text-shadow: 1px 1px 0px rgba(255,255,255,.15);
109
  }
110
 
111
- .slider:before {
112
  content: 'OFF';
113
  margin-top: -3px;
114
  font: 12px/26px Arial, sans-serif;
@@ -119,7 +133,7 @@ h3.title {
119
  font-weight: bold;
120
  }
121
 
122
- .slider label {
123
  display: block;
124
  width: 37px;
125
  height: 24px;
@@ -140,14 +154,14 @@ h3.title {
140
  -webkit-box-shadow: 0 1px 0 #006799;
141
  box-shadow: 0 2px 0 #006799;
142
  }
143
- .slider label:hover {
144
  background: #008ec2;
145
  }
146
 
147
- .slider input[type=checkbox] {
148
  visibility: hidden;
149
  }
150
 
151
- .slider input[type=checkbox]:checked + label {
152
  left: 43px;
153
- }
1
  /*
2
  * My Custom Functions
3
  * Style sheet for plugin's page
4
+ * @since 2.5
5
  * @agareginyan
6
  */
7
 
10
  text-align: center;
11
  }
12
 
13
+ /* Titles
14
+ -------------------------------------------------------------- */
15
  h2 {
16
  text-align: center;
17
  font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
33
  h3.title {
34
  font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
35
  border-bottom: 1px solid #eee;
 
36
  }
37
 
38
+ /* Messages
39
+ -------------------------------------------------------------- */
40
  #setting-error-settings_updated {
41
  display: none;
42
  }
43
 
44
+ /* CodeMirror Editor
45
+ -------------------------------------------------------------- */
46
  .CodeMirror {
47
  height: 100% !important;
48
+ border: 1px solid #ddd;
49
  margin-left: 5px;
50
  margin-right: 5px;
51
  }
52
 
53
+ /* Sidebar
54
+ -------------------------------------------------------------- */
55
  #side-sortables {
56
  position: relative;
57
  }
80
  margin-top: 5px;
81
  }
82
 
83
+ /* Responsive
84
+ -------------------------------------------------------------- */
85
+ @media (max-width: 860px) {
86
+ .inner-sidebar {
87
+ display: none !important;
88
+ }
89
+ #post-body-content {
90
+ margin-right: 0 !important;
91
+ }
92
+ }
93
+
94
  /* On/Off Trigger
95
  -------------------------------------------------------------- */
96
+ .trigger {
97
  margin-left: auto;
98
  margin-right: 0;
99
  margin-top: -20px;
110
  box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
111
  }
112
 
113
+ .trigger:after {
114
  content: 'ON';
115
  margin-top: -3px;
116
  font: 12px/26px Arial, sans-serif;
122
  text-shadow: 1px 1px 0px rgba(255,255,255,.15);
123
  }
124
 
125
+ .trigger:before {
126
  content: 'OFF';
127
  margin-top: -3px;
128
  font: 12px/26px Arial, sans-serif;
133
  font-weight: bold;
134
  }
135
 
136
+ .trigger label {
137
  display: block;
138
  width: 37px;
139
  height: 24px;
154
  -webkit-box-shadow: 0 1px 0 #006799;
155
  box-shadow: 0 2px 0 #006799;
156
  }
157
+ .trigger label:hover {
158
  background: #008ec2;
159
  }
160
 
161
+ .trigger input[type=checkbox] {
162
  visibility: hidden;
163
  }
164
 
165
+ .trigger input[type=checkbox]:checked + label {
166
  left: 43px;
167
+ }
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-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"
@@ -21,25 +21,25 @@ msgstr ""
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
- #: inc/settings_page.php:21
25
  msgid "Custom functions updated successfully."
26
  msgstr "Пользовательские функции успешно обновлены."
27
 
28
- #: inc/settings_page.php:32
29
  msgid "Sorry, but your code causes a \"Fatal error\", so it is not applied!"
30
  msgstr ""
31
  "Извините, но ваш код вызывает \"Fatal error\", так что он не будет применён!"
32
 
33
- #: inc/settings_page.php:33
34
  msgid "Please, check the code and try again."
35
  msgstr "Пожалуйста, проверьте код и попробуйте еще раз."
36
 
37
  #. Plugin Name of the plugin/theme
38
- #: inc/settings_page.php:43 my-custom-functions.php:82
39
  msgid "My Custom Functions"
40
  msgstr ""
41
 
42
- #: inc/settings_page.php:46
43
  msgid ""
44
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
45
  "Gareginyan</a>"
@@ -47,23 +47,23 @@ msgstr ""
47
  "от <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Артур "
48
  "Гарегинян</a>"
49
 
50
- #: inc/settings_page.php:57
51
  msgid "About"
52
  msgstr "О плагине"
53
 
54
- #: inc/settings_page.php:59
55
  msgid ""
56
- "This plugin allows you to easily and safely add your own functions, snippets "
57
- "or any custom code to your website."
58
  msgstr ""
59
- "Этот плагин позволяет легко и безопасно добавлять свои собственные функции, "
60
- "сниппеты или любой пользовательский код на ваш веб-сайт."
61
 
62
- #: inc/settings_page.php:64
63
  msgid "Using"
64
  msgstr "Использование:"
65
 
66
- #: inc/settings_page.php:66
67
  msgid ""
68
  "To use, enter your custom functions, then click \"Save Changes\". It's that "
69
  "simple!"
@@ -71,19 +71,19 @@ msgstr ""
71
  "Для использования, введите ваши пользовательские функции, затем нажмите "
72
  "кнопку “Сохранить изменения”. Это так просто!"
73
 
74
- #: inc/settings_page.php:71
75
  msgid "Help"
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"
84
  msgstr "Пожертвование"
85
 
86
- #: inc/settings_page.php:82
87
  msgid ""
88
  "If you like this plugin and find it useful, help me to make this plugin even "
89
  "better and keep it up-to-date."
@@ -91,15 +91,15 @@ msgstr ""
91
  "Если вам нравится этот плагин и вы находите его полезным, то помогите мне "
92
  "сделать его ещё лучше."
93
 
94
- #: inc/settings_page.php:86
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
 
@@ -117,12 +117,12 @@ msgstr ""
117
 
118
  #. Description of the plugin/theme
119
  msgid ""
120
- "Easily and safely add your own functions, snippets or any custom codes "
121
- "directly out of your WordPress Dashboard without need of an external editor."
122
  msgstr ""
123
- "Просто и безопасно добавляйте свои собственные функции, сниппеты или любые "
124
- "пользовательские коды непосредственно из вашего WordPress Dashboard без "
125
- "необходимости во внешнем редакторе."
126
 
127
  #. Author of the plugin/theme
128
  msgid "Arthur Gareginyan"
@@ -132,6 +132,25 @@ msgstr "Артур Гарегинян"
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>"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: My Custom Functions\n"
4
+ "POT-Creation-Date: 2016-07-26 19:52+0300\n"
5
+ "PO-Revision-Date: 2016-07-26 19:52+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: ru\n"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
+ #: inc/settings_page.php:23
25
  msgid "Custom functions updated successfully."
26
  msgstr "Пользовательские функции успешно обновлены."
27
 
28
+ #: inc/settings_page.php:34
29
  msgid "Sorry, but your code causes a \"Fatal error\", so it is not applied!"
30
  msgstr ""
31
  "Извините, но ваш код вызывает \"Fatal error\", так что он не будет применён!"
32
 
33
+ #: inc/settings_page.php:35
34
  msgid "Please, check the code and try again."
35
  msgstr "Пожалуйста, проверьте код и попробуйте еще раз."
36
 
37
  #. Plugin Name of the plugin/theme
38
+ #: inc/settings_page.php:45 my-custom-functions.php:82
39
  msgid "My Custom Functions"
40
  msgstr ""
41
 
42
+ #: inc/settings_page.php:48
43
  msgid ""
44
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
45
  "Gareginyan</a>"
47
  "от <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Артур "
48
  "Гарегинян</a>"
49
 
50
+ #: inc/settings_page.php:59
51
  msgid "About"
52
  msgstr "О плагине"
53
 
54
+ #: inc/settings_page.php:61
55
  msgid ""
56
+ "This plugin allows you to easily and safely add your custome functions (PHP "
57
+ "code) to your website."
58
  msgstr ""
59
+ "Этот плагин даёт вам возможность легко и безопасно добавлять ваши "
60
+ "пользовательские функции (PHP код) на ваш веб-сайт."
61
 
62
+ #: inc/settings_page.php:66
63
  msgid "Using"
64
  msgstr "Использование:"
65
 
66
+ #: inc/settings_page.php:68
67
  msgid ""
68
  "To use, enter your custom functions, then click \"Save Changes\". It's that "
69
  "simple!"
71
  "Для использования, введите ваши пользовательские функции, затем нажмите "
72
  "кнопку “Сохранить изменения”. Это так просто!"
73
 
74
+ #: inc/settings_page.php:73
75
  msgid "Help"
76
  msgstr "Помощь"
77
 
78
+ #: inc/settings_page.php:75
79
  msgid "Got something to say? Need help?"
80
  msgstr "Есть что сказать? Нужна помощь?"
81
 
82
+ #: inc/settings_page.php:81
83
  msgid "Donate"
84
  msgstr "Пожертвование"
85
 
86
+ #: inc/settings_page.php:84
87
  msgid ""
88
  "If you like this plugin and find it useful, help me to make this plugin even "
89
  "better and keep it up-to-date."
91
  "Если вам нравится этот плагин и вы находите его полезным, то помогите мне "
92
  "сделать его ещё лучше."
93
 
94
+ #: inc/settings_page.php:88
95
  msgid "Thanks for your support!"
96
  msgstr "Спасибо за вашу поддержку!"
97
 
98
+ #: inc/settings_page.php:112
99
+ msgid "Functions (PHP code)"
100
+ msgstr "Функции (PHP код)"
101
 
102
+ #: inc/settings_page.php:123
103
  msgid "Save Changes"
104
  msgstr "Сохранить изменения"
105
 
117
 
118
  #. Description of the plugin/theme
119
  msgid ""
120
+ "Easily and safely add your custome functions (PHP code) directly out of your "
121
+ "WordPress Dashboard without need of an external editor."
122
  msgstr ""
123
+ "Просто и безопасно добавляйте ваши пользовательские функции ((PHP code) "
124
+ "непосредственно из админ панели вашего WordPress вебсайта, без необходимости "
125
+ "во внешнем редакторе."
126
 
127
  #. Author of the plugin/theme
128
  msgid "Arthur Gareginyan"
132
  msgid "http://www.arthurgareginyan.com"
133
  msgstr ""
134
 
135
+ #~ msgid "Functions"
136
+ #~ msgstr "Функции"
137
+
138
+ #~ msgid ""
139
+ #~ "This plugin allows you to easily and safely add your own functions, "
140
+ #~ "snippets or any custom code to your website."
141
+ #~ msgstr ""
142
+ #~ "Этот плагин позволяет легко и безопасно добавлять свои собственные "
143
+ #~ "функции, сниппеты или любой пользовательский код на ваш веб-сайт."
144
+
145
+ #~ msgid ""
146
+ #~ "Easily and safely add your own functions, snippets or any custom codes "
147
+ #~ "directly out of your WordPress Dashboard without need of an external "
148
+ #~ "editor."
149
+ #~ msgstr ""
150
+ #~ "Просто и безопасно добавляйте свои собственные функции, сниппеты или "
151
+ #~ "любые пользовательские коды непосредственно из вашего WordPress Dashboard "
152
+ #~ "без необходимости во внешнем редакторе."
153
+
154
  #~ msgid ""
155
  #~ "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
156
  #~ "\"Berserkr\" Gareginyan</a>"
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-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"
@@ -20,76 +20,76 @@ msgstr ""
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
- #: inc/settings_page.php:21
24
  msgid "Custom functions updated successfully."
25
  msgstr ""
26
 
27
- #: inc/settings_page.php:32
28
  msgid "Sorry, but your code causes a \"Fatal error\", so it is not applied!"
29
  msgstr ""
30
 
31
- #: inc/settings_page.php:33
32
  msgid "Please, check the code and try again."
33
  msgstr ""
34
 
35
  #. Plugin Name of the plugin/theme
36
- #: inc/settings_page.php:43 my-custom-functions.php:82
37
  msgid "My Custom Functions"
38
  msgstr ""
39
 
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
47
  msgid "About"
48
  msgstr ""
49
 
50
- #: inc/settings_page.php:59
51
  msgid ""
52
- "This plugin allows you to easily and safely add your own functions, snippets "
53
- "or any custom code to your website."
54
  msgstr ""
55
 
56
- #: inc/settings_page.php:64
57
  msgid "Using"
58
  msgstr ""
59
 
60
- #: inc/settings_page.php:66
61
  msgid ""
62
  "To use, enter your custom functions, then click \"Save Changes\". It's that "
63
  "simple!"
64
  msgstr ""
65
 
66
- #: inc/settings_page.php:71
67
  msgid "Help"
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
75
  msgid "Donate"
76
  msgstr ""
77
 
78
- #: inc/settings_page.php:82
79
  msgid ""
80
  "If you like this plugin and find it useful, help me to make this plugin even "
81
  "better and keep it up-to-date."
82
  msgstr ""
83
 
84
- #: inc/settings_page.php:86
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
 
@@ -107,8 +107,8 @@ msgstr ""
107
 
108
  #. Description of the plugin/theme
109
  msgid ""
110
- "Easily and safely add your own functions, snippets or any custom codes "
111
- "directly out of your WordPress Dashboard without need of an external editor."
112
  msgstr ""
113
 
114
  #. Author of the plugin/theme
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: My Custom Functions\n"
6
+ "POT-Creation-Date: 2016-07-26 19:52+0300\n"
7
  "PO-Revision-Date: 2015-08-30 16:22+0300\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
+ #: inc/settings_page.php:23
24
  msgid "Custom functions updated successfully."
25
  msgstr ""
26
 
27
+ #: inc/settings_page.php:34
28
  msgid "Sorry, but your code causes a \"Fatal error\", so it is not applied!"
29
  msgstr ""
30
 
31
+ #: inc/settings_page.php:35
32
  msgid "Please, check the code and try again."
33
  msgstr ""
34
 
35
  #. Plugin Name of the plugin/theme
36
+ #: inc/settings_page.php:45 my-custom-functions.php:82
37
  msgid "My Custom Functions"
38
  msgstr ""
39
 
40
+ #: inc/settings_page.php:48
41
  msgid ""
42
  "by <a href=\"http://www.arthurgareginyan.com\" target=\"_blank\">Arthur "
43
  "Gareginyan</a>"
44
  msgstr ""
45
 
46
+ #: inc/settings_page.php:59
47
  msgid "About"
48
  msgstr ""
49
 
50
+ #: inc/settings_page.php:61
51
  msgid ""
52
+ "This plugin allows you to easily and safely add your custome functions (PHP "
53
+ "code) to your website."
54
  msgstr ""
55
 
56
+ #: inc/settings_page.php:66
57
  msgid "Using"
58
  msgstr ""
59
 
60
+ #: inc/settings_page.php:68
61
  msgid ""
62
  "To use, enter your custom functions, then click \"Save Changes\". It's that "
63
  "simple!"
64
  msgstr ""
65
 
66
+ #: inc/settings_page.php:73
67
  msgid "Help"
68
  msgstr ""
69
 
70
+ #: inc/settings_page.php:75
71
  msgid "Got something to say? Need help?"
72
  msgstr ""
73
 
74
+ #: inc/settings_page.php:81
75
  msgid "Donate"
76
  msgstr ""
77
 
78
+ #: inc/settings_page.php:84
79
  msgid ""
80
  "If you like this plugin and find it useful, help me to make this plugin even "
81
  "better and keep it up-to-date."
82
  msgstr ""
83
 
84
+ #: inc/settings_page.php:88
85
  msgid "Thanks for your support!"
86
  msgstr ""
87
 
88
+ #: inc/settings_page.php:112
89
+ msgid "Functions (PHP code)"
90
  msgstr ""
91
 
92
+ #: inc/settings_page.php:123
93
  msgid "Save Changes"
94
  msgstr ""
95
 
107
 
108
  #. Description of the plugin/theme
109
  msgid ""
110
+ "Easily and safely add your custome functions (PHP code) directly out of your "
111
+ "WordPress Dashboard without need of an external editor."
112
  msgstr ""
113
 
114
  #. Author of the plugin/theme
my-custom-functions.php CHANGED
@@ -2,10 +2,10 @@
2
  /**
3
  * Plugin Name: My Custom Functions
4
  * Plugin URI: https://github.com/ArthurGareginyan/my-custom-functions
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.4
9
  * License: GPL3
10
  * Text Domain: my-custom-functions
11
  * Domain Path: /languages/
@@ -52,7 +52,7 @@ defined('MCFUNC_PATH') or define('MCFUNC_PATH', plugin_dir_path(__FILE__));
52
  * @since 2.2
53
  */
54
  function MCFunctions_textdomain() {
55
- load_plugin_textdomain( 'my-custom-functions', false, MCFUNC_DIR . '/languages/' );
56
  }
57
  add_action( 'init', 'MCFunctions_textdomain' );
58
 
@@ -67,9 +67,9 @@ add_action( 'init', 'MCFunctions_textdomain' );
67
  * @return array Array of links to be output on Plugin Admin page.
68
  */
69
  function MCFunctions_settings_link( $links ) {
70
- $settings_page = '<a href="' . admin_url( 'themes.php?page=my-custom-functions.php' ) .'">' . __( 'Settings', 'my-custom-functions' ) . '</a>';
71
- array_unshift( $links, $settings_page );
72
- return $links;
73
  }
74
  add_filter( "plugin_action_links_".MCFUNC_BASE, 'MCFunctions_settings_link' );
75
 
@@ -79,7 +79,7 @@ add_filter( "plugin_action_links_".MCFUNC_BASE, 'MCFunctions_settings_link' );
79
  * @since 2.2
80
  */
81
  function MCFunctions_register_submenu_page() {
82
- add_theme_page( __( 'My Custom Functions', 'my-custom-functions' ), __( 'Custom Functions', 'my-custom-functions' ), 'edit_theme_options', basename( __FILE__ ), 'MCFunctions_render_submenu_page' );
83
  }
84
  add_action( 'admin_menu', 'MCFunctions_register_submenu_page' );
85
 
@@ -96,17 +96,17 @@ require_once( MCFUNC_PATH . 'inc/settings_page.php' );
96
  * @since 2.0
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
 
111
  // Return if the page is not a settings page of this plugin
112
  if ( 'appearance_page_my-custom-functions' != $hook ) {
@@ -116,6 +116,7 @@ function MCFunctions_enqueue_codemirror_scripts($hook) {
116
  // CodeMirror
117
  wp_enqueue_script('codemirror', MCFUNC_URL . 'inc/codemirror/codemirror-compressed.js');
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);
@@ -123,7 +124,7 @@ function MCFunctions_enqueue_codemirror_scripts($hook) {
123
  // Style sheet
124
  wp_enqueue_style('styles', MCFUNC_URL . 'inc/style.css');
125
  }
126
- add_action( 'admin_enqueue_scripts', 'MCFunctions_enqueue_codemirror_scripts' );
127
 
128
  /**
129
  * Prepare the user entered code for execution
@@ -144,7 +145,7 @@ function MCFunctions_prepare($content) {
144
  /**
145
  * Check the user entered code for duplicate names of functions
146
  *
147
- * @since 2.4
148
  */
149
  function MCFunctions_duplicates($content) {
150
 
@@ -163,7 +164,6 @@ function MCFunctions_duplicates($content) {
163
  update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
164
  $error_status = '1';
165
  } else {
166
- update_option( 'anarcho_cfunctions_error', '0' ); // RESET ERROR VALUE
167
  $error_status = '0';
168
  }
169
 
@@ -172,31 +172,23 @@ function MCFunctions_duplicates($content) {
172
  }
173
 
174
  /**
175
- * Execute the user code
176
  *
177
- * @since 2.4
178
  */
179
  function MCFunctions_exec() {
180
 
181
  // Read data from DB
182
  $options = get_option( 'anarcho_cfunctions_settings' );
183
- $content = isset( $options['anarcho_cfunctions-content'] ) && ! empty( $options['anarcho_cfunctions-content'] ) ? $options['anarcho_cfunctions-content'] : ' ';
184
  $enable = isset( $options['enable'] ) && !empty( $options['enable'] ) ? $options['enable'] : ' ';
185
-
186
- // Get the error status
187
- $duplicates = MCFunctions_duplicates($content);
188
-
189
- // If the custom code is disabled...
190
- if ( $enable == "on") {
191
- return; // EXIT
192
- }
193
 
194
- // If the duplicates functions finded...
195
- if ( $duplicates != 0 ) {
196
  return; // EXIT
197
  }
198
 
199
- // Get the user entered functions by calling the "prepare" function
200
  $content = MCFunctions_prepare($content);
201
 
202
  // If content is empty...
@@ -204,6 +196,12 @@ function MCFunctions_exec() {
204
  return; // EXIT
205
  }
206
 
 
 
 
 
 
 
207
  // Parsing and execute by Eval
208
  if( false === @eval( $content ) ) {
209
  update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
@@ -220,8 +218,8 @@ MCFunctions_exec();
220
  * @since 0.1
221
  */
222
  function MCFunctions_uninstall() {
223
- delete_option( 'anarcho_cfunctions_settings' );
224
- delete_option( 'anarcho_cfunctions_error' );
225
  }
226
  register_uninstall_hook( __FILE__, 'MCFunctions_uninstall' );
227
 
2
  /**
3
  * Plugin Name: My Custom Functions
4
  * Plugin URI: https://github.com/ArthurGareginyan/my-custom-functions
5
+ * Description: Easily and safely add your custome functions (PHP code) 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.5
9
  * License: GPL3
10
  * Text Domain: my-custom-functions
11
  * Domain Path: /languages/
52
  * @since 2.2
53
  */
54
  function MCFunctions_textdomain() {
55
+ load_plugin_textdomain( 'my-custom-functions', false, MCFUNC_DIR . '/languages/' );
56
  }
57
  add_action( 'init', 'MCFunctions_textdomain' );
58
 
67
  * @return array Array of links to be output on Plugin Admin page.
68
  */
69
  function MCFunctions_settings_link( $links ) {
70
+ $settings_page = '<a href="' . admin_url( 'themes.php?page=my-custom-functions.php' ) .'">' . __( 'Settings', 'my-custom-functions' ) . '</a>';
71
+ array_unshift( $links, $settings_page );
72
+ return $links;
73
  }
74
  add_filter( "plugin_action_links_".MCFUNC_BASE, 'MCFunctions_settings_link' );
75
 
79
  * @since 2.2
80
  */
81
  function MCFunctions_register_submenu_page() {
82
+ add_theme_page( __( 'My Custom Functions', 'my-custom-functions' ), __( 'Custom Functions', 'my-custom-functions' ), 'edit_theme_options', basename( __FILE__ ), 'MCFunctions_render_submenu_page' );
83
  }
84
  add_action( 'admin_menu', 'MCFunctions_register_submenu_page' );
85
 
96
  * @since 2.0
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
+ * Load scripts and style sheet for settings page
106
  *
107
+ * @since 2.5
108
  */
109
+ function MCFunctions_load_scripts($hook) {
110
 
111
  // Return if the page is not a settings page of this plugin
112
  if ( 'appearance_page_my-custom-functions' != $hook ) {
116
  // CodeMirror
117
  wp_enqueue_script('codemirror', MCFUNC_URL . 'inc/codemirror/codemirror-compressed.js');
118
  wp_enqueue_style('codemirror_style', MCFUNC_URL . 'inc/codemirror/codemirror.css');
119
+ wp_enqueue_script('codemirror-active-line', MCFUNC_URL . 'inc/codemirror/addons/active-line.js');
120
 
121
  // JS functions
122
  wp_enqueue_script('js-functions', MCFUNC_URL . 'inc/functions.js', array(), false, true);
124
  // Style sheet
125
  wp_enqueue_style('styles', MCFUNC_URL . 'inc/style.css');
126
  }
127
+ add_action( 'admin_enqueue_scripts', 'MCFunctions_load_scripts' );
128
 
129
  /**
130
  * Prepare the user entered code for execution
145
  /**
146
  * Check the user entered code for duplicate names of functions
147
  *
148
+ * @since 2.5
149
  */
150
  function MCFunctions_duplicates($content) {
151
 
164
  update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
165
  $error_status = '1';
166
  } else {
 
167
  $error_status = '0';
168
  }
169
 
172
  }
173
 
174
  /**
175
+ * Execute the user entered code
176
  *
177
+ * @since 2.5
178
  */
179
  function MCFunctions_exec() {
180
 
181
  // Read data from DB
182
  $options = get_option( 'anarcho_cfunctions_settings' );
183
+ $content = isset( $options['anarcho_cfunctions-content'] ) && !empty( $options['anarcho_cfunctions-content'] ) ? $options['anarcho_cfunctions-content'] : ' ';
184
  $enable = isset( $options['enable'] ) && !empty( $options['enable'] ) ? $options['enable'] : ' ';
 
 
 
 
 
 
 
 
185
 
186
+ // If the user entered code is disabled...
187
+ if ( $enable == 'on') {
188
  return; // EXIT
189
  }
190
 
191
+ // Prepare the user entered functions by calling the "prepare" function
192
  $content = MCFunctions_prepare($content);
193
 
194
  // If content is empty...
196
  return; // EXIT
197
  }
198
 
199
+ // If the duplicates functions finded...
200
+ $duplicates = MCFunctions_duplicates($content);
201
+ if ( $duplicates != 0 ) {
202
+ return; // EXIT
203
+ }
204
+
205
  // Parsing and execute by Eval
206
  if( false === @eval( $content ) ) {
207
  update_option( 'anarcho_cfunctions_error', '1' ); // ERROR
218
  * @since 0.1
219
  */
220
  function MCFunctions_uninstall() {
221
+ delete_option( 'anarcho_cfunctions_settings' );
222
+ delete_option( 'anarcho_cfunctions_error' );
223
  }
224
  register_uninstall_hook( __FILE__, 'MCFunctions_uninstall' );
225
 
readme.txt CHANGED
@@ -3,26 +3,28 @@ Contributors: Arthur Gareginyan
3
  Tags: code, php, function, snippet, custom, execute, edit, editing, editor, functionality plugin, codemirror, syntax highlighting, syntaxhighlighting, syntax highlighter, syntaxhighlighter, syntax, highlighting, highlighter,
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.3
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
- Easily and safely add your own functions, snippets or any custom codes directly out of your WordPress Dashboard without need of an external editor.
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
  * Checks the entered code for fatal errors (simple checks)
21
  * Syntax highlighting (by CodeMirror)
22
- * Line numbering (by CodeMirror)
23
- * Trigger for temporary disable the custom functions (PHP code)
 
 
24
  * Ready for translation (.pot file included)
25
- * Russian translation
26
 
27
  **Coming soon:**
28
  * Reload the settings page at same position after pushing the save button
@@ -30,6 +32,11 @@ An easy to use WordPress plugin that gives you the ability to easily and safely
30
  * Backup of all custom functions to file
31
  * Easier disable/enable option for WSOD
32
 
 
 
 
 
 
33
 
34
  >**Contribution**
35
  >
@@ -135,12 +142,20 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
135
 
136
 
137
  == Changelog ==
 
 
 
 
 
 
 
 
138
  = 2.4 =
139
- * Added trigger for temporary disable the custom functions (PHP code).
140
  * Functions _prepare, _duplicates, and _exec optimized.
141
  = 2.3 =
142
- * Added function to check for duplicate function names. Compares the names of all functions (internal, user).
143
- * Added function for automatic remove the message about successful saving after 3 seconds.
144
  * Removed the default message about successful saving.
145
  * The function of user code cleaning modified.
146
  * File js-functions.js renamed to functions.js.
3
  Tags: code, php, function, snippet, custom, execute, edit, editing, editor, functionality plugin, codemirror, syntax highlighting, syntaxhighlighting, syntax highlighter, syntaxhighlighter, syntax, highlighting, highlighter,
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.6
7
+ Stable tag: 2.5
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
+ Easily and safely add your custome functions (PHP code) directly out of your WordPress Dashboard without need of an external editor.
12
 
13
 
14
  == Description ==
15
+ An easy to use WordPress plugin that gives you the ability to easily and safely add your custome functions (PHP code) 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
+ * Responsive & Mobile optimized settings page
21
  * Checks the entered code for fatal errors (simple checks)
22
  * Syntax highlighting (by CodeMirror)
23
+ * Line numbering
24
+ * Active line highlighting
25
+ * Editor allow for tab indentation
26
+ * Trigger for temporary disable the custom functions
27
  * Ready for translation (.pot file included)
 
28
 
29
  **Coming soon:**
30
  * Reload the settings page at same position after pushing the save button
32
  * Backup of all custom functions to file
33
  * Easier disable/enable option for WSOD
34
 
35
+ = Translation =
36
+
37
+ * English
38
+ * Russian
39
+ * Chinese (Taiwan)
40
 
41
  >**Contribution**
42
  >
142
 
143
 
144
  == Changelog ==
145
+ = 2.5 =
146
+ * Added active-line addon to CodeMirror.
147
+ * Extra update_option() removed from the _duplicates function.
148
+ * The _exec function optimized.
149
+ * CSS class "slider" renamed to "trigger".
150
+ * Styles of settings page optimized for mobile devices.
151
+ * The styles.css file better commented.
152
+ * The _enqueue_codemirror_scripts function renamed to mcstyles_load_scripts.
153
  = 2.4 =
154
+ * Added trigger for temporary disable the custom functions.
155
  * Functions _prepare, _duplicates, and _exec optimized.
156
  = 2.3 =
157
+ * Added function to check for duplicate function names. Compares the names of all functions (internal, user). The _duplicates function added.
158
+ * Added function for automatic remove the "successful" message after 3 seconds.
159
  * Removed the default message about successful saving.
160
  * The function of user code cleaning modified.
161
  * File js-functions.js renamed to functions.js.