PHP code example of develtio / wp-theme-settings
1. Go to this page and download the library: Download develtio/wp-theme-settings library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
develtio / wp-theme-settings example snippets
namespace Develtio\WP\ThemeSettings;
$parent = acf_add_options_page(
[
'page_title' => 'Theme settings',
'menu_title' => 'Theme settings',
'menu_slug' => 'options_theme',
'capability' => 'edit_posts',
'icon_url' => 'dashicons-smiley',
'redirect' => false,
'position' => 5,
]
);
acf_add_options_sub_page(
[
'page_title' => 'Analytics',
'menu_title' => 'Analytics',
'parent_slug' => 'options_theme',
'menu_slug' => $parent['menu_slug'] . '_analytics',
]
);
namespace Develtio\WP\ThemeSettings;
acf_add_options_page(
[
'page_title' => 'News settings',
'menu_title' => 'News settings',
'menu_slug' => 'options_news',
'capability' => 'edit_posts',
'icon_url' => 'dashicons-smiley',
'redirect' => false,
'position' => 2,
'parent_slug' => 'edit.php?post_type=news',
]
);
namespace Develtio\WP\ThemeSettings;
use StoutLogic\AcfBuilder\FieldsBuilder;
$fields = new FieldsBuilder('header');
$fields
->addText('title')
->addTextarea('description');
return $fields;
namespace Develtio\WP\ThemeSettings;
use StoutLogic\AcfBuilder\FieldsBuilder;
$fields = new FieldsBuilder('template_home', ['title' => 'Template Home']);
$fields->setLocation('page_template', '==', 'views/template-home.blade.php');
$fields
->addTab('header')
->addGroup('header')
->addFields(Settings::getFieldPartial('components.header'))
->endGroup()
->addTab('cards')
->addText('cards_section_title')
->addRepeater('cards')
->addFields(Settings::getFieldPartial('components.card'))
->endRepeater();
return $fields;
namespace Develtio\WP\ThemeSettings;
$postTypeArgs = function () {
$labels = [
'name' => _x('Blog', 'post type general name', 'develtio'),
'singular_name' => _x('Blog', 'post type singular name', 'develtio'),
];
$args = [
'labels' => $labels,
'public' => true,
'hierarchical' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 40,
'menu_icon' => 'dashicons-admin-post',
'supports' => ['title', 'editor', 'thumbnail'],
'has_archive' => true,
'rewrite' => ['slug' => 'blog', 'with_front' => false],
];
return $args;
};
register_post_type('blog', $postTypeArgs());
namespace Develtio\WP\ThemeSettings;
$taxonomyArgs = function () {
$labels = [
'name' => _x('Blog categories', 'taxonomy general name', 'develtio'),
'singular_name' => _x('Blog category', 'taxonomy singular name', 'develtio'),
];
$args = [
'labels' => $labels,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => false,
];
return $args;
};
register_taxonomy('blog_cat', ['blog'], $taxonomyArgs());