PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.5
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.5
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Modules / CustomHeaderFooter / CustomHeaderFooter.php

CustomHeaderFooter.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.5, at Inc/Modules/CustomHeaderFooter/CustomHeaderFooter.php

138 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\CustomHeaderFooter;
4
5 use WPAdminify\Inc\Utils ;
6 use WPAdminify\Inc\Modules\CustomHeaderFooter\CustomHeaderFooterModel ;
7 // no direct access allowed
8 if ( !defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 /**
12 * WPAdminify
13 * @package Custom CSS/JS
14 *
15 * @author Jewel Theme <support@jeweltheme.com>
16 */
17 class CustomHeaderFooter extends CustomHeaderFooterModel
18 {
19 public $url ;
20 public function __construct()
21 {
22 $this->url = WP_ADMINIFY_URL . 'Inc/Modules/CustomHeaderFooter';
23 $this->options = ( new CustomHeaderFooterSettings() )->get();
24 $this->options = ( !empty($this->options['custom_scripts']) ? $this->options['custom_scripts'] : '' );
25 if ( is_admin() ) {
26 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
27 }
28 add_action( 'wp_head', [ $this, 'adminify_header_scripts' ], 9999 );
29 add_action( 'wp_footer', [ $this, 'adminify_footer_scripts' ], 9999 );
30 add_action( 'the_content', [ $this, 'adminify_content_scripts' ] );
31 }
32
33 // Add Header Scripts
34 public function adminify_header_scripts()
35 {
36 $this->adminify_custom_css_js_script( 'header' );
37 }
38
39 // Add Footer Scripts
40 public function adminify_footer_scripts()
41 {
42 $this->adminify_custom_css_js_script( 'footer' );
43 }
44
45 // Add Footer Scripts
46 public function adminify_content_scripts( $content )
47 {
48 return $this->adminify_custom_css_js_script( false, $content );
49 }
50
51 /**
52 * Render Snippet
53 *
54 * @param [since] 1.0.0
55 *
56 * @return void
57 */
58 public function render_snippet( $value )
59 {
60 // $device_display = wp_is_mobile() ? 'desktop' : 'mobile';
61
62 if ( $value['script_type'] == 'css' ) {
63 echo "\n<!-- Start of WP Adminify Custom CSS - Snippet#{$value['title']} -->\n" ;
64 echo '<style>' ;
65 echo "\n{$value['custom_css']}\n" ;
66 echo '</style>' ;
67 echo "\n<!-- /End of WP Adminify Custom CSS -->\n" ;
68 } elseif ( $value['script_type'] === 'js' ) {
69 echo "\n<!-- Start of WP Adminify Custom JS - Snippet#{$value['title']} -->\n" ;
70 echo '<script>' ;
71 echo "\n{$value['custom_js']}\n" ;
72 echo '</script>' ;
73 echo "\n<!-- /End of WP Adminify Custom JS -->\n" ;
74 }
75
76 }
77
78 /**
79 * Add Snippet
80 *
81 * @return void
82 */
83 public function adminify_custom_css_js_script( $location = '', $content = '' )
84 {
85 $options = $this->options;
86 $before_content = '';
87 $after_content = '';
88 if ( !empty($options) ) {
89 foreach ( $options as $key => $value ) {
90 $output = '';
91 if ( $value['location'] === $location ) {
92 switch ( $value['display_on'] ) {
93 case 'full_site':
94 $output = $this->render_snippet( $value );
95 break;
96 case 's_posts':
97 break;
98 case 's_pages':
99 break;
100 case 's_categories':
101 break;
102 case 's_custom_posts':
103 break;
104 case 's_tags':
105 break;
106 }
107 }
108 }
109 }
110 return $before_content . $content . $after_content;
111 }
112
113 /**
114 * Scripts/Styles
115 */
116 public function enqueue_scripts()
117 {
118 global $pagenow ;
119 // Load Scripts/Styles only WP Adminify Custom CSS/JS Page
120 if ( 'admin.php' === $pagenow && 'adminify-custom-css-js' === $_GET['page'] ) {
121 $this->header_footer_admin_script();
122 }
123 }
124
125 // WP Adminify Custom CSS/JS Page Style
126 public function header_footer_admin_script()
127 {
128 echo '<style>.wp-adminify-custom-css-js .adminify-container{ max-width:60%; margin:0 auto;} .wp-adminify-custom-css-js .adminify-header-inner{padding:0;}.wp-adminify-custom-css-js .adminify-field-subheading{font-size:20px; padding-left:0;}.adminify-custom-css-js .adminify-nav,.adminify-custom-css-js .adminify-search,.adminify-custom-css-js .adminify-footer,.adminify-custom-css-js .adminify-reset-all,.adminify-custom-css-js .adminify-expand-all,.adminify-custom-css-js .adminify-header-left,.adminify-custom-css-js .adminify-reset-section,.adminify-custom-css-js .adminify-nav-background{display: none !important;}.adminify-custom-css-js .adminify-nav-normal + .adminify-content{margin-left: 0;}
129
130 /* If needed for white top-bar */
131 .adminify-custom-css-js .adminify-header-inner {
132 background-color: #fafafa !important;
133 border-bottom: 1px solid #f5f5f5;
134 }
135 </style>' ;
136 }
137
138 }