PluginProbe
Admin and Site Enhancements (ASE) / 7.5.3
Admin and Site Enhancements (ASE) v7.5.3
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 All 273 releases
admin-site-enhancements / classes / class-insert-head-body-footer-code.php
class-insert-head-body-footer-code.php
84 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class for Insert <head>, <body> and <footer> code module
7 *
8 * @since 6.9.5
9 */
10 class Insert_Head_Body_Footer_Code {
11
12 /**
13 * Insert code before </head> tag
14 *
15 * @since 3.3.0
16 */
17 public function insert_head_code() {
18
19 $this->insert_code( 'head' );
20
21 }
22
23 /**
24 * Insert code after <body> tag
25 *
26 * @since 3.3.0
27 */
28 public function insert_body_code() {
29
30 $this->insert_code( 'body' );
31
32 }
33
34 /**
35 * Insert code in footer section before </body> tag
36 *
37 * @since 3.3.0
38 */
39 public function insert_footer_code() {
40
41 $this->insert_code( 'footer' );
42
43 }
44
45 /**
46 * Insert code
47 *
48 * @since 3.3.0
49 */
50 public function insert_code( $location ) {
51
52 // Do not insert code in admin, feed, robots or trackbacks
53 if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
54 return;
55 }
56
57 // Get option that stores the code
58 $options = get_option( ASENHA_SLUG_U, array() );
59
60 if ( 'head' == $location ) {
61
62 $code = array_key_exists( 'head_code', $options ) ? $options['head_code'] : '';
63
64 }
65
66 if ( 'body' == $location ) {
67
68 $code = array_key_exists( 'body_code', $options ) ? $options['body_code'] : '';
69
70 }
71
72 if ( 'footer' == $location ) {
73
74 $code = array_key_exists( 'footer_code', $options ) ? $options['footer_code'] : '';
75
76 }
77
78 // [TODO] Properly escape code
79 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
80 echo wp_unslash( $code ) . PHP_EOL;
81
82 }
83
84 }