Adding extention options

This commit is contained in:
Nilambar Sharma 2018-09-04 16:48:24 +05:45
parent af1b44b4e7
commit 467dd4f01f
3 changed files with 83 additions and 40 deletions

View file

@ -17,9 +17,9 @@ define( 'ALX_EXTENSIONS_BASENAME', basename( dirname( __FILE__ ) ) );
define( 'ALX_EXTENSIONS_DIR', rtrim( plugin_dir_path( __FILE__ ), '/' ) );
define( 'ALX_EXTENSIONS_URL', rtrim( plugin_dir_url( __FILE__ ), '/' ) );
require_once ALX_EXTENSIONS_DIR . '/inc/options.php';
require_once ALX_EXTENSIONS_DIR . '/inc/share.php';
require_once ALX_EXTENSIONS_DIR . '/inc/post-formats.php';
require_once ALX_EXTENSIONS_DIR . '/inc/sidebar.php';
/* load plugin textdomain */
function alx_ext_load_textdomain() {

82
inc/options.php Normal file
View file

@ -0,0 +1,82 @@
<?php
add_action( 'after_setup_theme', 'alx_ext_custom_options', 11 );
function alx_ext_custom_options() {
if ( ! class_exists( 'Kirki' ) ) {
return;
}
Kirki::add_config( 'alx_extensions', array(
'capability' => 'edit_theme_options',
'option_type' => 'theme_mod',
) );
Kirki::add_panel( 'alx_extensions_panel', array(
'priority' => 11,
'title' => esc_html__( 'Theme Extensions', 'alx-extensions' ),
) );
Kirki::add_section( 'alx_extensions_social', array(
'priority' => 10,
'title' => esc_html__( 'Social Share', 'alx-extensions' ),
'panel' => 'alx_extensions_panel',
) );
Kirki::add_field( 'enable_social_share', array(
'type' => 'switch',
'settings' => 'enable_social_share',
'label' => esc_html__( 'Enable Social Share', 'alx-extensions' ),
'section' => 'alx_extensions_social',
'default' => 'on',
) );
Kirki::add_section( 'alx_extensions_upscale', array(
'priority' => 10,
'title' => esc_html__( 'Image Upscale', 'alx-extensions' ),
'panel' => 'alx_extensions_panel',
) );
Kirki::add_field( 'enable_image_upscale', array(
'type' => 'switch',
'settings' => 'enable_image_upscale',
'label' => esc_html__( 'Enable Image Upscale', 'alx-extensions' ),
'section' => 'alx_extensions_upscale',
'default' => 'on',
) );
Kirki::add_section( 'alx_extensions_custom_sidebars', array(
'priority' => 10,
'title' => esc_html__( 'Custom Sidebars', 'alx-extensions' ),
'panel' => 'alx_extensions_panel',
) );
// Sidebars: Create Sidebars
Kirki::add_field( 'alx_sidebar', array(
'type' => 'repeater',
'label' => esc_html__( 'Create Sidebars', 'alx-extensions' ),
'description' => esc_html__( 'You must save and refresh the page to see your new sidebars.', 'alx-extensions' ),
'tooltip' => esc_html__( 'Make sure that you save and refresh the page if you can not see the sidebars you have created.', 'alx-extensions' ),
'section' => 'alx_extensions_custom_sidebars',
'row_label' => array(
'type' => 'text',
'value' => esc_html__('sidebar', 'alx-extensions' ),
),
'settings' => 'sidebar-areas',
'default' => '',
'fields' => array(
'title' => array(
'type' => 'text',
'label' => esc_html__( 'Sidebar Title', 'alx-extensions' ),
'description' => esc_html__( 'The widget box title', 'alx-extensions' ),
'default' => '',
),
'id' => array(
'type' => 'text',
'label' => esc_html__( 'Sidebar ID', 'alx-extensions' ),
'description' => esc_html__( 'This ID must be unique', 'alx-extensions' ),
'default' => 'sidebar-',
),
)
) );
}

View file

@ -1,39 +0,0 @@
<?php
add_action( 'after_setup_theme', 'alx_ext_custom_sidebars', 11 );
function alx_ext_custom_sidebars() {
if ( ! class_exists( 'Kirki' ) ) {
return;
}
// Sidebars: Create Sidebars
Kirki::add_field( 'alx_theme', array(
'type' => 'repeater',
'label' => esc_html__( 'Create Sidebars', 'alx-extensions' ),
'description' => esc_html__( 'You must save and refresh the page to see your new sidebars.', 'alx-extensions' ),
'tooltip' => esc_html__( 'Make sure that you save and refresh the page if you can not see the sidebars you have created.', 'alx-extensions' ),
'section' => 'sidebars',
'row_label' => array(
'type' => 'text',
'value' => esc_html__('sidebar', 'alx-extensions' ),
),
'settings' => 'sidebar-areas',
'default' => '',
'fields' => array(
'title' => array(
'type' => 'text',
'label' => esc_html__( 'Sidebar Title', 'alx-extensions' ),
'description' => esc_html__( 'The widget box title', 'alx-extensions' ),
'default' => '',
),
'id' => array(
'type' => 'text',
'label' => esc_html__( 'Sidebar ID', 'alx-extensions' ),
'description' => esc_html__( 'This ID must be unique', 'alx-extensions' ),
'default' => 'sidebar-',
),
)
) );
}