Add on/off option for custom widgets

This commit is contained in:
Alexander Agnarson 2019-01-16 13:58:23 +01:00
parent 23d5b51bb7
commit 8cf4a571d8
3 changed files with 46 additions and 5 deletions

View file

@ -21,8 +21,6 @@ require_once ALX_EXTENSIONS_DIR . '/inc/options.php';
require_once ALX_EXTENSIONS_DIR . '/inc/share.php';
require_once ALX_EXTENSIONS_DIR . '/inc/share-footer.php';
require_once ALX_EXTENSIONS_DIR . '/inc/post-formats.php';
require_once ALX_EXTENSIONS_DIR . '/inc/widgets/alx-posts.php';
require_once ALX_EXTENSIONS_DIR . '/inc/widgets/alx-tabs.php';
/* Load plugin textdomain
@ -110,3 +108,12 @@ function alx_ext_register_custom_sidebars() {
add_action( 'widgets_init', 'alx_ext_register_custom_sidebars', 11 );
/* Custom widgets
/* ------------------------------------ */
if ( get_theme_mod( 'widget-alx-posts', 'on' ) == 'on') {
require_once ALX_EXTENSIONS_DIR . '/inc/widgets/alx-posts.php';
}
if ( get_theme_mod( 'widget-alx-tabs', 'on' ) == 'on') {
require_once ALX_EXTENSIONS_DIR . '/inc/widgets/alx-tabs.php';
}

View file

@ -88,4 +88,26 @@ function alx_ext_custom_options() {
),
)
) );
Kirki::add_section( 'alx_extensions_widgets', array(
'priority' => 11,
'title' => esc_html__( 'Custom Widgets', 'alx' ),
'panel' => 'alx_extensions_panel',
) );
Kirki::add_field( 'alx_posts', array(
'type' => 'switch',
'settings' => 'widget-alx-posts',
'label' => esc_html__( 'Alx Posts', 'alx' ),
'section' => 'alx_extensions_widgets',
'default' => 'on',
) );
Kirki::add_field( 'alx_tabs', array(
'type' => 'switch',
'settings' => 'widget-alx-tabs',
'label' => esc_html__( 'Alx Tabs', 'alx' ),
'section' => 'alx_extensions_widgets',
'default' => 'on',
) );
}

View file

@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Alx Extensions\n"
"POT-Creation-Date: 2019-01-15 13:44+0100\n"
"POT-Creation-Date: 2019-01-16 13:57+0100\n"
"PO-Revision-Date: 2018-09-21 21:27+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -83,6 +83,18 @@ msgstr ""
msgid "This ID must be unique"
msgstr ""
#: inc/options.php:94
msgid "Custom Widgets"
msgstr ""
#: inc/options.php:101
msgid "Alx Posts"
msgstr ""
#: inc/options.php:109
msgid "Alx Tabs"
msgstr ""
#: inc/post-formats.php:12
msgid "Format: Audio"
msgstr ""
@ -129,7 +141,7 @@ msgid "Share on LinkedIn"
msgstr ""
#: inc/widgets/alx-posts.php:19
msgid "Alx Posts"
msgid "Alx Posts (plugin)"
msgstr ""
#: inc/widgets/alx-posts.php:19
@ -217,7 +229,7 @@ msgid "Show dates"
msgstr ""
#: inc/widgets/alx-tabs.php:19
msgid "Alx Tabs"
msgid "Alx Tabs (plugin)"
msgstr ""
#: inc/widgets/alx-tabs.php:19