__('Primary Menu', 'aj-square'),
));
register_sidebar(array(
'name' => __('Main Sidebar', 'aj-square'),
'id' => 'main-sidebar',
'description' => __('Widgets added here will appear in the main sidebar.', 'aj-square'),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
));
}
add_action( 'init', 'ajsquare_register_block_styles' );
function ajsquare_register_block_styles() {
// Example: Add custom styles to core/quote
register_block_style( 'core/quote', array(
'name' => 'fancy-quote',
'label' => __( 'Fancy Quote', 'aj-square' ),
'inline_style' => '.is-style-fancy-quote { font-style: italic; border-left: 4px solid #333; padding-left: 10px; }',
) );
}
add_action('after_setup_theme', 'ajsquare_setup');
// Enqueue scripts and styles
function ajsquare_scripts() {
// Theme main stylesheet
wp_enqueue_style('aj-square-root-style', get_stylesheet_uri(), array(), '1.0.0');
// Theme custom style
wp_enqueue_style('aj-square-style', get_template_directory_uri() . '/assets/css/style.css', array(), '1.0.0');
// Bootstrap (local)
wp_enqueue_style('bootstrap-css', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), '4.6.2');
// Font Awesome (local)
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/assets/css/fontawesome.min.css', array(), '6.4.2');
// Bootstrap Icons (local)
wp_enqueue_style('bootstrap-icons', get_template_directory_uri() . '/assets/bootstrap-icons/bootstrap-icons.css', array(), '1.10.5');
// jQuery (use default from WordPress)
// Do not deregister!
// Bootstrap JS (local)
wp_enqueue_script('bootstrap-js', get_template_directory_uri() . '/assets/js/bootstrap.bundle.min.js', array('jquery'), '4.6.2', true);
// Custom JS (local)
wp_enqueue_script('aj-square-script', get_template_directory_uri() . '/assets/js/script.js', array('jquery'), '1.1.0', true);
}
add_action('wp_enqueue_scripts', 'ajsquare_scripts');
// Enqueue admin styles
function aj_enqueue_admin_styles() {
wp_enqueue_style('aj-admin-style', get_template_directory_uri() . '/assets/css/admin-style.css', array(), '1.0.0');
// Enqueue comment reply if needed
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action('admin_enqueue_scripts', 'aj_enqueue_admin_styles');
// Elementor compatibility
function ajsquare_elementor_support() {
add_theme_support('elementor');
}
add_action('after_setup_theme', 'ajsquare_elementor_support');
// Content width
if (!isset($content_width)) {
$content_width = 1140;
}
// Excerpt function
function excerpt($num) {
global $post;
$limit = $num + 1;
$excerpt = explode(' ', get_the_excerpt(), $limit);
array_pop($excerpt);
$excerpt = implode(" ", $excerpt) . " Read More »";
echo $excerpt;
}
// Reading time
function get_reading_time($post_id) {
$content = get_post_field('post_content', $post_id);
$word_count = str_word_count(strip_tags($content));
return ceil($word_count / 200);
}
// Time ago format
function time_ago($post_id) {
$post_time = get_post_time('U', true, $post_id);
$time_difference = time() - $post_time;
if ($time_difference < 1) return 'Just now';
$time_units = array(
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($time_units as $unit => $unit_name) {
if ($time_difference >= $unit) {
$num = floor($time_difference / $unit);
return $num . ' ' . $unit_name . ($num > 1 ? 's' : '') . ' ago';
}
}
}
// Custom pagination
function pagination($pages = '', $range = 4){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == ''){
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) $pages = 1;
}
if(1 != $pages){
echo "\n";
}
}
// Header widget area
function register_header_widget_area() {
register_sidebar(array(
'name' => __('Header Widget Area', 'aj-square'),
'id' => 'header-widget-area',
'before_widget' => '',
'before_title' => '',
'after_title' => '',
));
}
add_action('widgets_init', 'register_header_widget_area');
// Custom logo widget
function custom_logo_widget_init() {
register_sidebar(array(
'name' => __('Custom Logo Widget', 'aj-square'),
'id' => 'custom_logo_widget',
'before_widget' => '',
'after_widget' => '
',
));
}
add_action('widgets_init', 'custom_logo_widget_init');
// Homepage heading customization
function ajsquare_customize_register($wp_customize) {
// Add a section for the homepage heading
$wp_customize->add_section('homepage_settings', array(
'title' => __('Homepage Text Settings', 'aj-square'),
'priority' => 30,
));
// Add a setting for the homepage heading
$wp_customize->add_setting('homepage_heading', array(
'default' => __('Shaping Ideas into Reality', 'aj-square'),
'sanitize_callback' => 'sanitize_text_field',
));
// Add a setting for the homepage subheading
$wp_customize->add_setting('homepage_subheading', array(
'default' => __('We are a team of passionate developers and designers.', 'aj-square'),
'sanitize_callback' => 'sanitize_text_field',
));
// Add a setting for the homepage description
$wp_customize->add_setting('homepage_description', array(
'default' => __('We create beautiful and functional websites.', 'aj-square'),
'sanitize_callback' => 'sanitize_textarea_field',
));
// Add a control to edit the homepage heading
$wp_customize->add_control('homepage_heading_control', array(
'label' => __('Homepage Heading', 'aj-square'),
'section' => 'homepage_settings',
'settings' => 'homepage_heading',
'type' => 'text',
));
// Add a control to edit the homepage subheading
$wp_customize->add_control('homepage_subheading_control', array(
'label' => __('Homepage Subheading', 'aj-square'),
'section' => 'homepage_settings',
'settings' => 'homepage_subheading',
'type' => 'text',
));
// Add a control to edit the homepage description
$wp_customize->add_control('homepage_description_control', array(
'label' => __('Homepage Description', 'aj-square'),
'section' => 'homepage_settings',
'settings' => 'homepage_description',
'type' => 'textarea',
));
}
add_action('customize_register', 'ajsquare_customize_register');
/* Hero Section Widget Area */
function register_hero_section_widget_area() {
register_sidebar(array(
'name' => __('Hero Section Widget Area', 'aj-square'),
'id' => 'hero-section-widget-area',
'before_widget' => '',
'after_widget' => '
',
));
}
add_action('widgets_init', 'register_hero_section_widget_area');
// Custom Block widget area
function ajsquare_register_custom_block() {
register_sidebar(array(
'name' => __('Custom Block', 'aj-square'),
'id' => 'custom-block',
'before_widget' => '',
'after_widget' => '
',
));
}
add_action('widgets_init', 'ajsquare_register_custom_block');
// Custom Hero Secition widget area
function ajsquare_register_addnew_hero_section() {
register_sidebar(array(
'name' => __('Add New Section', 'aj-square'),
'id' => 'addnew-hero-section',
'before_widget' => '',
'after_widget' => '
',
));
}
add_action('widgets_init', 'ajsquare_register_addnew_hero_section');
// Register FAQ widget area
function ajsquare_register_faq_widget_area() {
register_sidebar(array(
'name' => __('FAQ Widget Area', 'aj-square'),
'id' => 'faq-widget-area',
'before_widget' => '',
'after_widget' => '
',
));
}
add_action('widgets_init', 'ajsquare_register_faq_widget_area');
// Register Footer UP custom Section type
function register_footerup_widget_area() {
register_sidebar(array(
'name' => __('FooterUp Widget Area', 'aj-square'),
'id' => 'footerup-widget-area',
'before_widget' => '',
));
}
add_action('widgets_init', 'register_footerup_widget_area');
/*------------------------------------------------------
Footer Section Area
-------------------------------------------------------*/
//Footer Social media widget area
function ajsquare_register_footer_social_media() {
register_sidebar(array(
'name' => __('Footer Social Media', 'aj-square'),
'id' => 'footer-social-media',
'before_widget' => '',
));
}
add_action('widgets_init', 'ajsquare_register_footer_social_media');
/*---------------------------------------------------
Documentation Function
----------------------------------------------------*/
function ajsquare_add_documentation_menu() {
add_menu_page(
__('AJ SQUARE', 'aj-square'), // Page title
__('AJ SQUARE', 'aj-square'), // Menu title
'manage_options', // Capability required to access the page
'aj-square-docs', // Menu slug
'ajsquare_theme_docs', // Callback function to render the page content
'dashicons-book', // Icon for the menu
60 // Position (use a lower value for above Appearance or higher for below)
);
}
add_action('admin_menu', 'ajsquare_add_documentation_menu');
// Render the Documentation Page Content
function ajsquare_theme_docs() {
?>
- Themes".', 'aj-square'); ?>
Customize" and adjust the settings as per your preferences.', 'aj-square'); ?>