| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Modules\LoginCustomizer\Inc\Settings; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Modules\LoginCustomizer\Inc\Customize_Model; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
die; |
| 9 |
} // Cannot access directly. |
| 10 |
|
| 11 |
class Custom_CSS_JS extends Customize_Model { |
| 12 |
|
| 13 |
public function __construct() { |
| 14 |
$this->custom_css_js_customizer(); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_defaults() { |
| 18 |
return [ |
| 19 |
'jltwp_adminify_customizer_custom_css' => '', |
| 20 |
'jltwp_adminify_customizer_custom_js' => '', |
| 21 |
]; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
public function custom_css_js_fields_settings( &$custom_css_js_fields ) { |
| 26 |
$custom_css_js_fields[] = [ |
| 27 |
'id' => 'jltwp_adminify_customizer_custom_css', |
| 28 |
'type' => 'code_editor', |
| 29 |
'title' => 'CSS Editor', |
| 30 |
'subtitle' => sprintf( __( 'Custom CSS doesn\'t work on live. Save Settings and Preview %1$s login%2$s page or hit refresh after save Customer.', 'adminify' ), '<a href="' . wp_login_url() . '"title="Login" target="_blank">', '</a>' ), |
| 31 |
'desc' => __( 'Don\'t place <style></style> tag inside editor.', 'adminify' ), |
| 32 |
'settings' => [ |
| 33 |
'theme' => 'monokai', |
| 34 |
'mode' => 'css', |
| 35 |
], |
| 36 |
'sanitize' => false, |
| 37 |
'default' => $this->get_default_field( 'jltwp_adminify_customizer_custom_css' ), |
| 38 |
]; |
| 39 |
|
| 40 |
$custom_css_js_fields[] = [ |
| 41 |
'id' => 'jltwp_adminify_customizer_custom_js', |
| 42 |
'type' => 'code_editor', |
| 43 |
'title' => __( 'JS Editor', 'adminify' ), |
| 44 |
'subtitle' => sprintf( __( 'Custom JS doesn\'t work on live. Save Settings and Preview %1$s login%2$s page or hit refresh after save Customer.', 'adminify' ), '<a href="' . wp_login_url() . '"title="Login" target="_blank">', '</a>' ), |
| 45 |
'desc' => __( 'Don\'t place <script></script> tag inside editor.', 'adminify' ), |
| 46 |
'settings' => [ |
| 47 |
'theme' => 'dracula', |
| 48 |
'mode' => 'javascript', |
| 49 |
], |
| 50 |
'sanitize' => false, |
| 51 |
'default' => $this->get_default_field( 'jltwp_adminify_customizer_custom_js' ), |
| 52 |
]; |
| 53 |
} |
| 54 |
|
| 55 |
public function custom_css_js_customizer() { |
| 56 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
$custom_css_js_fields = []; |
| 61 |
$this->custom_css_js_fields_settings( $custom_css_js_fields ); |
| 62 |
|
| 63 |
/** |
| 64 |
* Section: Custom CSS & JS Section |
| 65 |
*/ |
| 66 |
\ADMINIFY::createSection( |
| 67 |
$this->prefix, |
| 68 |
[ |
| 69 |
'assign' => 'jltwp_adminify_customizer_custom_css_js_section', |
| 70 |
'title' => __( 'Custom CSS & JS', 'adminify' ), |
| 71 |
'fields' => $custom_css_js_fields, |
| 72 |
] |
| 73 |
); |
| 74 |
} |
| 75 |
} |
| 76 |
|