Start Theme Repo

This commit is contained in:
2026-01-29 19:10:03 +01:00
commit 101179e994
84 changed files with 14654 additions and 0 deletions

150
src/Theme/Customizer.php Normal file
View File

@@ -0,0 +1,150 @@
<?php
namespace RomhackPlaza\Theme;
defined( '\ABSPATH' ) || exit;
use RomhackPlaza\Theme\Script;
use RomhackPlaza\Theme\Script_Type;
class Customizer {
public function __construct() {
add_action( 'customize_register', array( $this, 'custom_panel' ) );
add_action( 'customize_controls_print_style', array( $this, 'custom_preview_css' ) );
add_action( 'customize_preview_init', array( $this, 'custom_preview_js' ) );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'custom_controls_js' ) );
// --- Sections ---
new Customizer\General();
new Customizer\Blog();
new Customizer\Post();
new Customizer\Extends_Website();
}
/**
* Add custom panel to "Customize" menu.
* @param $wp_customize
* @return void
*/
public function custom_panel( $wp_customize ) {
$wp_customize->add_panel(
'romhackplaza_options_panel',
[
'priority' => 69,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => esc_html__( 'Theme Options', 'romhackplaza' ),
]
);
$wp_customize->get_control( 'background_color' )->section = 'background_image';
$wp_customize->get_control( 'background_image' )->title = esc_html__( 'Background', 'romhackplaza' );
}
public function custom_preview_css() {
// Keep Treville name for backwards compatibility.
new Script(
Script_Type::CSS,
'treville-customizer-css',
get_template_directory_uri() . '/assets/treville/css/customizer.css',
[],
'20200410'
)->enqueue();
new Script(
Script_Type::CSS,
'treville-pro-customizer-css',
get_template_directory_uri() . '/assets/treville-pro/css/customizer.css',
[],
'20210212'
)->enqueue();
}
public function custom_preview_js() {
// Keep Treville name for backwards compatibility.
new Script(
Script_Type::JS,
'treville-customizer-preview',
get_stylesheet_directory_uri() . '/assets/treville/js/customizer-preview.js',
[ 'customize-preview' ],
'20200410',
args: true
)->enqueue();
new Script(
Script_Type::JS,
'treville-pro-customizer-js',
get_stylesheet_directory_uri() . '/assets/treville-pro/js/customizer-preview.js',
[ 'customize-preview' ],
'20210309',
args: true
)->enqueue();
}
public function custom_controls_js() {
// Keep Treville name for backwards compatibility.
new Script(
Script_Type::JS,
'treville-customizer-controls',
get_stylesheet_directory_uri() . '/assets/treville/js/customizer-controls.js',
[],
'20200410',
args: true
)->enqueue();
}
// --- Check Functions ---
/**
* Verify if checkbox is correctly checked or not.
* From Treville.
*
* @param $checked
* @return bool
*/
public static function sanitize_checkbox( $checked ): bool {
return isset( $checked ) && true === $checked;
}
/**
* Verify if select or radio is correctly checked or not.
* From Treville.
*
* @param $input
* @param $setting
* @return string
*/
public static function sanitize_select( $input, $setting ): string {
$input = sanitize_key( $input );
$choices = $setting->manager->get_control( $setting->id )->choices;
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
/**
* Check if the post content is the excerpt for the theme.
* @param $control
* @return bool
*/
public static function post_content_equals_excerpt( $control ): bool{
return $control->manager->get_setting( 'romhackplaza_theme_options[post_content]' )->value() === 'excerpt';
}
public static function active_slider( $control ): bool {
return $control->manager->get_setting( 'romhackplaza_theme_options[slider_active]' )->value() === 'active';
}
}