Head and Footer Scripts Inserter - Version 4.2

Version Description

  • Compatibility with PHP version 5.2 improved.
  • PHP shorthands improved.
  • Added function for generating the plugin constants.
  • Some constants now get the value from the plugin header data.
  • The "_plugin_version_number" function improved.
  • Added file "upgrade.php" for future upgrades.
Download this release

Release Info

Developer Arthur Gareginyan
Plugin Icon 128x128 Head and Footer Scripts Inserter
Version 4.2
Comparing to
See all releases

Code changes from version 4.1.1 to 4.2

header-and-footer-scripts-inserter.php CHANGED
@@ -5,27 +5,25 @@
5
  * Description: Easily add your scripts to the WordPress website's head and footer sections. This is a must have tool for authors and website's owners.
6
  * Author: Arthur Gareginyan
7
  * Author URI: http://www.arthurgareginyan.com
8
- * Version: 4.1.1
9
  * License: GPL3
10
  * Text Domain: header-and-footer-scripts-inserter
11
  * Domain Path: /languages/
12
  *
13
  * Copyright 2016-2017 Arthur Gareginyan (email : arthurgareginyan@gmail.com)
14
  *
15
- * This file is part of "Head and Footer Scripts Inserter".
16
- *
17
- * "Head and Footer Scripts Inserter" is free software: you can redistribute it and/or modify
18
  * it under the terms of the GNU General Public License as published by
19
  * the Free Software Foundation, either version 3 of the License, or
20
  * (at your option) any later version.
21
  *
22
- * "Head and Footer Scripts Inserter" is distributed in the hope that it will be useful,
23
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
  * GNU General Public License for more details.
26
  *
27
  * You should have received a copy of the GNU General Public License
28
- * along with "Head and Footer Scripts Inserter". If not, see <http://www.gnu.org/licenses/>.
29
  *
30
  *
31
  * █████╗ ██████╗ ████████╗██╗ ██╗██╗ ██╗██████╗
@@ -55,27 +53,34 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
55
  /**
56
  * Define global constants
57
  *
58
- * @since 4.1
59
  */
60
- defined( 'HFSINS_DIR' ) or define( 'HFSINS_DIR', dirname( plugin_basename( __FILE__ ) ) );
61
- defined( 'HFSINS_BASE' ) or define( 'HFSINS_BASE', plugin_basename( __FILE__ ) );
62
- defined( 'HFSINS_URL' ) or define( 'HFSINS_URL', plugin_dir_url( __FILE__ ) );
63
- defined( 'HFSINS_PATH' ) or define( 'HFSINS_PATH', plugin_dir_path( __FILE__ ) );
64
- defined( 'HFSINS_TEXT' ) or define( 'HFSINS_TEXT', 'header-and-footer-scripts-inserter' );
65
- defined( 'HFSINS_SLUG' ) or define( 'HFSINS_SLUG', 'header-and-footer-scripts-inserter' );
66
- defined( 'HFSINS_PREFIX' ) or define( 'HFSINS_PREFIX', 'HFScriptsIns' );
67
- defined( 'HFSINS_SETTINGS' ) or define( 'HFSINS_SETTINGS', 'HFScriptsIns' );
68
- defined( 'HFSINS_NAME' ) or define( 'HFSINS_NAME', 'Head and Footer Scripts Inserter' );
69
- defined( 'HFSINS_VERSION' ) or define( 'HFSINS_VERSION', '4.1.1' );
 
 
 
 
 
 
70
 
71
  /**
72
  * Load the plugin modules
73
  *
74
- * @since 4.0
75
  */
76
  require_once( HFSINS_PATH . 'inc/php/core.php' );
77
- require_once( HFSINS_PATH . 'inc/php/enqueue.php' );
78
  require_once( HFSINS_PATH . 'inc/php/version.php' );
 
79
  require_once( HFSINS_PATH . 'inc/php/functional.php' );
80
  require_once( HFSINS_PATH . 'inc/php/page.php' );
81
  require_once( HFSINS_PATH . 'inc/php/messages.php' );
5
  * Description: Easily add your scripts to the WordPress website's head and footer sections. This is a must have tool for authors and website's owners.
6
  * Author: Arthur Gareginyan
7
  * Author URI: http://www.arthurgareginyan.com
8
+ * Version: 4.2
9
  * License: GPL3
10
  * Text Domain: header-and-footer-scripts-inserter
11
  * Domain Path: /languages/
12
  *
13
  * Copyright 2016-2017 Arthur Gareginyan (email : arthurgareginyan@gmail.com)
14
  *
15
+ * This plugin is free software: you can redistribute it and/or modify
 
 
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation, either version 3 of the License, or
18
  * (at your option) any later version.
19
  *
20
+ * This plugin is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
+ * along with this plugin. If not, see <http://www.gnu.org/licenses/>.
27
  *
28
  *
29
  * █████╗ ██████╗ ████████╗██╗ ██╗██╗ ██╗██████╗
53
  /**
54
  * Define global constants
55
  *
56
+ * @since 4.2
57
  */
58
+ $plugin_data = get_file_data( __FILE__, array( 'name'=>'Plugin Name', 'version'=>'Version', 'text'=>'Text Domain' ) );
59
+ function HFScriptsIns_define_constants( $constant_name, $value ) {
60
+ $constant_name = 'HFSINS_' . $constant_name;
61
+ if ( !defined( $constant_name ) )
62
+ define( $constant_name, $value );
63
+ }
64
+ HFScriptsIns_define_constants( 'DIR', dirname( plugin_basename( __FILE__ ) ) );
65
+ HFScriptsIns_define_constants( 'BASE', plugin_basename( __FILE__ ) );
66
+ HFScriptsIns_define_constants( 'URL', plugin_dir_url( __FILE__ ) );
67
+ HFScriptsIns_define_constants( 'PATH', plugin_dir_path( __FILE__ ) );
68
+ HFScriptsIns_define_constants( 'SLUG', dirname( plugin_basename( __FILE__ ) ) );
69
+ HFScriptsIns_define_constants( 'NAME', $plugin_data['name'] );
70
+ HFScriptsIns_define_constants( 'VERSION', $plugin_data['version'] );
71
+ HFScriptsIns_define_constants( 'TEXT', $plugin_data['text'] );
72
+ HFScriptsIns_define_constants( 'PREFIX', 'HFScriptsIns' );
73
+ HFScriptsIns_define_constants( 'SETTINGS', 'HFScriptsIns' );
74
 
75
  /**
76
  * Load the plugin modules
77
  *
78
+ * @since 4.2
79
  */
80
  require_once( HFSINS_PATH . 'inc/php/core.php' );
81
+ require_once( HFSINS_PATH . 'inc/php/upgrade.php' );
82
  require_once( HFSINS_PATH . 'inc/php/version.php' );
83
+ require_once( HFSINS_PATH . 'inc/php/enqueue.php' );
84
  require_once( HFSINS_PATH . 'inc/php/functional.php' );
85
  require_once( HFSINS_PATH . 'inc/php/page.php' );
86
  require_once( HFSINS_PATH . 'inc/php/messages.php' );
inc/php/messages.php CHANGED
@@ -48,12 +48,12 @@ function HFScriptsIns_hello_message() {
48
  /**
49
  * Error message (When the old version of plugin installed) - Bootstrap Modal
50
  *
51
- * @since 4.1
52
  */
53
  function HFScriptsIns_error_message() {
54
 
55
  $info = get_option( HFSINS_SETTINGS . '_service_info' );
56
- $old_version = isset( $info['old_version'] ) && !empty( $info['old_version'] ) ? $info['old_version'] : '0';
57
 
58
  if ( $old_version != '1' ) {
59
  return;
48
  /**
49
  * Error message (When the old version of plugin installed) - Bootstrap Modal
50
  *
51
+ * @since 4.2
52
  */
53
  function HFScriptsIns_error_message() {
54
 
55
  $info = get_option( HFSINS_SETTINGS . '_service_info' );
56
+ $old_version = !empty( $info['old_version'] ) ? $info['old_version'] : '0';
57
 
58
  if ( $old_version != '1' ) {
59
  return;
inc/php/page.php CHANGED
@@ -15,8 +15,8 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
15
  function HFScriptsIns_render_submenu_page() {
16
 
17
  // Call messages
18
- //HFScriptsIns_hello_message();
19
- //HFScriptsIns_error_message();
20
  HFScriptsIns_successfull_message();
21
 
22
  // Layout of page
15
  function HFScriptsIns_render_submenu_page() {
16
 
17
  // Call messages
18
+ HFScriptsIns_hello_message();
19
+ HFScriptsIns_error_message();
20
  HFScriptsIns_successfull_message();
21
 
22
  // Layout of page
inc/php/settings.php CHANGED
@@ -10,7 +10,7 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
10
  /**
11
  * Render Settings Tab
12
  *
13
- * @since 4.1
14
  */
15
  ?>
16
  <!-- SIDEBAR -->
@@ -54,14 +54,14 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
54
  <?php settings_fields( HFSINS_SETTINGS . '_settings_group' ); ?>
55
 
56
  <?php
57
- // Get options from the BD
58
  $options = get_option( HFSINS_SETTINGS . '_settings' );
59
 
60
- // Set default value if the option is empty
61
- $header_beginning = isset( $options['header_beginning'] ) && !empty( $options['header_beginning'] ) ? esc_attr( $options['header_beginning'] ) : '';
62
- $header_end = isset( $options['header_end'] ) && !empty( $options['header_end'] ) ? esc_attr( $options['header_end'] ) : '';
63
- $footer_beginning = isset( $options['footer_beginning'] ) && !empty( $options['footer_beginning'] ) ? esc_attr( $options['footer_beginning'] ) : '';
64
- $footer_end = isset( $options['footer_end'] ) && !empty( $options['footer_end'] ) ? esc_attr( $options['footer_end'] ) : '';
65
 
66
  // Add rows if all the rows is less than 10
67
  $type = array("header_beginning", "header_end", "footer_beginning", "footer_end");
10
  /**
11
  * Render Settings Tab
12
  *
13
+ * @since 4.2
14
  */
15
  ?>
16
  <!-- SIDEBAR -->
54
  <?php settings_fields( HFSINS_SETTINGS . '_settings_group' ); ?>
55
 
56
  <?php
57
+ // Get options from the database
58
  $options = get_option( HFSINS_SETTINGS . '_settings' );
59
 
60
+ // Set default value if option is empty
61
+ $header_beginning = !empty( $options['header_beginning'] ) ? esc_attr( $options['header_beginning'] ) : '';
62
+ $header_end = !empty( $options['header_end'] ) ? esc_attr( $options['header_end'] ) : '';
63
+ $footer_beginning = !empty( $options['footer_beginning'] ) ? esc_attr( $options['footer_beginning'] ) : '';
64
+ $footer_end = !empty( $options['footer_end'] ) ? esc_attr( $options['footer_end'] ) : '';
65
 
66
  // Add rows if all the rows is less than 10
67
  $type = array("header_beginning", "header_end", "footer_beginning", "footer_end");
inc/php/upgrade.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Prevent Direct Access
5
+ *
6
+ * @since 0.1
7
+ */
8
+ defined( 'ABSPATH' ) or die( "Restricted access!" );
inc/php/version.php CHANGED
@@ -10,7 +10,7 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
10
  /**
11
  * Function for managing information about the version number of the plugin
12
  *
13
- * @since 4.1
14
  */
15
  function HFScriptsIns_plugin_version_number() {
16
 
@@ -23,13 +23,16 @@ function HFScriptsIns_plugin_version_number() {
23
  if ( !is_array( $info ) ) {
24
  $info = array();
25
  }
26
- $current_number = isset( $info['version'] ) && !empty( $info['version'] ) ? $info['version'] : '0';
27
  $new_number = HFSINS_VERSION;
28
 
29
- // Call the upgrade function if the version number in the database is smaller than the 1.0
30
- //if ( $current_number < '1.0' ) {
31
- // HFScriptsIns_upgrade_1_0();
32
- //}
 
 
 
33
 
34
  // If the version number in the database is same as the new version number:
35
  // - Reset the "old_version" marker in the database
@@ -71,10 +74,4 @@ function HFScriptsIns_plugin_version_number() {
71
  }
72
 
73
  }
74
- //HFScriptsIns_plugin_version_number();
75
-
76
- // TEMPORARY FIX
77
- function HFScriptsIns_plugin_temp_fix() {
78
- delete_option( HFSINS_SETTINGS . '_service_info' );
79
- }
80
- HFScriptsIns_plugin_temp_fix();
10
  /**
11
  * Function for managing information about the version number of the plugin
12
  *
13
+ * @since 4.2
14
  */
15
  function HFScriptsIns_plugin_version_number() {
16
 
23
  if ( !is_array( $info ) ) {
24
  $info = array();
25
  }
26
+ $current_number = !empty( $info['version'] ) ? $info['version'] : '0';
27
  $new_number = HFSINS_VERSION;
28
 
29
+ // Update the "_service_info" data in the database if the version number is not number
30
+ if ( !is_numeric($current_number) ) {
31
+
32
+ $info['version'] = $new_number;
33
+ update_option( HFSINS_SETTINGS . '_service_info', $info );
34
+
35
+ }
36
 
37
  // If the version number in the database is same as the new version number:
38
  // - Reset the "old_version" marker in the database
74
  }
75
 
76
  }
77
+ HFScriptsIns_plugin_version_number();
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Arthur Gareginyan
3
  Tags: inject, insert, insert scripts, insert javascript, insert js, insert html, insert css, insert custom scripts, insert custom code, html, javascript, js, css, code, custom code, script, scripts, custom scripts, meta, meta tags, head, header, head section, head area, footer, footer section, footer area,
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.7
7
- Stable tag: 4.1.1
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -149,14 +149,22 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
149
 
150
  == Changelog ==
151
 
 
 
 
 
 
 
 
 
152
  = 4.1.1 =
153
- * Fixed the bug due to which the the "Warning: Constants may only evaluate to scalar values in " warnings are displayed.
154
 
155
  = 4.1 =
156
  * Added new constants: "_SLUG", "_PREFIX", "_SETTINGS" and "_NAME".
157
  * Value of the "_VERSION" constant replaced with information from the plugin header data.
158
  * All references to the plugin name, slug, prefix are replaced with constants.
159
- * The "name" attribute removed from the "<form>" tag.
160
  * Code formatting improved.
161
  * F.A.Q. section updated.
162
 
3
  Tags: inject, insert, insert scripts, insert javascript, insert js, insert html, insert css, insert custom scripts, insert custom code, html, javascript, js, css, code, custom code, script, scripts, custom scripts, meta, meta tags, head, header, head section, head area, footer, footer section, footer area,
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.8
7
+ Stable tag: 4.2
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
149
 
150
  == Changelog ==
151
 
152
+ = 4.2 =
153
+ * Compatibility with PHP version 5.2 improved.
154
+ * PHP shorthands improved.
155
+ * Added function for generating the plugin constants.
156
+ * Some constants now get the value from the plugin header data.
157
+ * The "_plugin_version_number" function improved.
158
+ * Added file "upgrade.php" for future upgrades.
159
+
160
  = 4.1.1 =
161
+ * Fixed the bug due to which the "Warning: Constants may only evaluate to scalar values in" warning are displayed.
162
 
163
  = 4.1 =
164
  * Added new constants: "_SLUG", "_PREFIX", "_SETTINGS" and "_NAME".
165
  * Value of the "_VERSION" constant replaced with information from the plugin header data.
166
  * All references to the plugin name, slug, prefix are replaced with constants.
167
+ * The "name" attribute removed from the "form" tag.
168
  * Code formatting improved.
169
  * F.A.Q. section updated.
170