a-staff Settings page to WP-Admin
add_filter( 'tpl_settings_pages', 'a_staff_settings_page', 10, 1 );
function a_staff_settings_page( $pages ) {
$pages["a_staff_settings"] = array(
"page_title" => __( 'a-staff Settings', 'a-staff' ),
"menu_title" => __( 'a-staff', 'a-staff' ),
"capability" => 'edit_theme_options',
"menu_slug" => 'a_staff_settings',
"function" => 'a_staff_settings',
"post_type" => 'a_staff_settings',
"menu_func" => 'add_menu_page'
);
return $pages;
}
$a_staff_orderby_options = array(
);
// Add plugin-specific sections and options
add_action( 'init', 'a_staff_setup', 30 );
function a_staff_setup() {
global $tpl_load_version, $a_staff_orderby_options;
// Dont'd do anything if our version of TPL Framework is lower than the required
if ( version_compare( $tpl_load_version["version"], A_STAFF_REQ_TPL_VERSION ) < 0 ) {
return;
}
// First set up the required sections
// Section for the a-staff Social settings
$section = array (
"name" => 'a_staff_social',
"tab" => __( 'Social', 'a-staff' ),
"title" => __( 'Social Networks setup', 'a-staff' ),
"description" => __( 'Set up the available social networks here for the a-staff plugin', 'a-staff' ),
"post_type" => 'a_staff_settings',
);
tpl_register_section ( $section );
// Section for the a-staff Layout settings
$section = array (
"name" => 'a_staff_layout',
"tab" => __( 'Layout', 'a-staff' ),
"title" => __( 'Layout settings', 'a-staff' ),
"description" => __( 'Settings for the front end layout of this plugin', 'a-staff' ),
"post_type" => 'a_staff_settings',
);
tpl_register_section ( $section );
// Section for the a-staff Responsive settings
$section = array (
"name" => 'a_staff_responsive',
"tab" => __( 'Responsive', 'a-staff' ),
"title" => __( 'Responsiveness settings', 'a-staff' ),
"description" => __( 'How should the plugin\'s output behave on small screens? Works only if you enabled the Load Basic Front end CSS setting on the Layout tab.', 'a-staff' ),
"post_type" => 'a_staff_settings',
);
tpl_register_section ( $section );
// Section for the a-staff Behavior settings
$section = array (
"name" => 'a_staff_behavior',
"tab" => __( 'Behavior', 'a-staff' ),
"title" => __( 'Behavior settings', 'a-staff' ),
"description" => __( 'A few settings about how should the shortcode work', 'a-staff' ),
"post_type" => 'a_staff_settings',
);
tpl_register_section ( $section );
// Section for the a-staff System settings
$section = array (
"name" => 'a_staff_system',
"tab" => __( 'System', 'a-staff' ),
"title" => __( 'System settings', 'a-staff' ),
"description" => __( 'Settings about how the plugin should work under the hood', 'a-staff' ),
"post_type" => 'a_staff_settings',
);
tpl_register_section ( $section );
// And now the options inside the sections
// Combined field: Social Networks
$tpl_option_array = array (
"name" => 'a_staff_social_networks',
"title" => __( 'Social Network manager', 'a-staff' ),
"description" => __( 'You can add/remove social networks here that will be available on Staff Member pages', 'a-staff' ),
"section" => 'a_staff_social',
"type" => 'combined',
"repeat" => true,
"repeat_button_title" => __( 'Add Social Network', 'a-staff' ),
"preview" => ' [network_name/tpl-preview-1]',
"parts" => array(
array(
"name" => 'network_name',
"title" => __( 'Name of the Social Network', 'a-staff' ),
"description" => __( 'This is the public name of the social network, it should be something like "Facebook", "Twitter", or similar.', 'a-staff' ),
"type" => 'text',
"placeholder" => __( 'Enter the name of the network here, e.g. "Facebook"', 'a-staff' ),
),
array(
"name" => 'network_icon',
"title" => __( 'Icon for the Social Network', 'a-staff' ),
"description" => __( 'Choose an icon for the Network', 'a-staff' ),
"type" => 'font_awesome',
"admin_class" => 'tpl-select-preview-key',
),
array(
"name" => 'icon_color',
"title" => __( 'Icon color', 'a-staff' ),
"description" => __( 'Set the color of this icon here.', 'a-staff' ),
"type" => 'color',
"default" => '#666666',
"condition" => array(
array(
"type" => 'option',
"name" => 'a_staff_icon_colors',
"relation" => '=',
"value" => true,
)
),
),
),
"less" => false,
);
tpl_register_option ( $tpl_option_array );
// Select field: where to open the social links
$tpl_option_array = array (
"name" => 'a_staff_social_target',
"title" => __( 'Social link target', 'a-staff' ),
"description" => __( 'Should it open in a new browser tab or in the same tab?', 'a-staff' ),
"section" => 'a_staff_social',
"type" => 'select',
"values" => array(
"same" => __( 'Same tab', 'a-staff' ),
"new" => __( 'New tab', 'a-staff' ),
),
"default" => 'new',
);
tpl_register_option ( $tpl_option_array );
// Select field: default size of the social icons
$tpl_option_array = array (
"name" => 'a_staff_social_icon_size',
"title" => __( 'Social icon size', 'a-staff' ),
"description" => sprintf( __( 'Size of the icon in %1$sFont Awesome sizes%2$s', 'a-staff' ), '', '' ),
"section" => 'a_staff_social',
"type" => 'select',
"default" => '2x',
"values" => array(
"xs" => __( 'Extra Small', 'a-staff' ),
"sm" => __( 'Small', 'a-staff' ),
"1x" => __( 'Normal', 'a-staff' ),
"lg" => __( 'Larger', 'a-staff' ),
"2x" => __( 'Double', 'a-staff' ),
"3x" => __( 'Triple', 'a-staff' ),
"4x" => __( '4x', 'a-staff' ),
"5x" => __( '5x', 'a-staff' ),
"6x" => __( '6x', 'a-staff' ),
"7x" => __( '7x', 'a-staff' ),
"8x" => __( '8x', 'a-staff' ),
"9x" => __( '9x', 'a-staff' ),
"10x" => __( '10x', 'a-staff' ),
),
"key" => true,
);
tpl_register_option ( $tpl_option_array );
// Select field: whether to enable custom colors for icons or not
$tpl_option_array = array (
"name" => 'a_staff_icon_colors',
"title" => __( 'Enable icon colors?', 'a-staff' ),
"description" => __( 'If enabled, you can specify the color of each social icon separately. Otherwise they will use the default theme colors.', 'a-staff' ),
"section" => 'a_staff_social',
"type" => 'boolean',
"default" => false,
);
tpl_register_option ( $tpl_option_array );
// Select field: whether to enable phone numbers for the staff members
$tpl_option_array = array (
"name" => 'a_staff_enable_phone_numbers',
"title" => __( 'Enable phone numbers?', 'a-staff' ),
"description" => __( 'If enabled, you can add phone numbers to the staff member boxes.', 'a-staff' ),
"section" => 'a_staff_social',
"type" => 'boolean',
"default" => false,
);
tpl_register_option ( $tpl_option_array );
// Number field: number of columns in the shortcode's output
$tpl_option_array = array (
"name" => 'a_staff_columns',
"title" => __( 'Number of columns', 'a-staff' ),
"description" => __( 'The default number of columns to be used when displaying staff members in the front end. You can override this setting with the shortcode\'s columns attribute.
In the current version 1 to 6 columns are supported.', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'number',
"min" => 1,
"max" => 6,
"step" => 1,
"default" => 3,
);
tpl_register_option ( $tpl_option_array );
// Select field: Should the member bio be formatted with wpautop()?
$tpl_option_array = array (
"name" => 'a_staff_format_bio',
"title" => __( 'Add some formatting to the member bio?', 'a-staff' ),
"description" => __( 'If eanbled, the new lines will be displayed in the member descriptions.', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'boolean',
"default" => false,
);
tpl_register_option ( $tpl_option_array );
// Number field: number of words to be used when bio is formatted
$tpl_option_array = array (
"name" => 'a_staff_bio_length',
"title" => __( 'Length of member bio', 'a-staff' ),
"description" => __( 'Maximum length of member bio in words. Currently only available if the bio is formatted.', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'number',
"min" => 1,
"step" => 1,
"default" => 55,
"condition" => array(
array(
"type" => 'option',
"name" => 'a_staff_format_bio',
"relation" => '=',
"value" => true,
),
),
);
tpl_register_option ( $tpl_option_array );
// Select field: the image size displayed in the member boxes
$image_sizes = array();
foreach ( a_staff_get_image_sizes() as $key => $size ) {
$image_sizes[$key] = $key . ' (' . $size["width"] . 'x' . $size["height"];
if ( $size["crop"] ) {
$image_sizes[$key] .= 'c';
}
$image_sizes[$key] .= ')';
}
$tpl_option_array = array (
"name" => 'a_staff_image_size',
"title" => __( 'Image sizes in member boxes', 'a-staff' ),
"description" => __( 'Which image size should we use in the staff member boxes when it\'s displayed in the front end? (\'c\' at the end means that the image is cropped)', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'select',
"values" => $image_sizes,
"default" => 'a-staff-default',
"key" => true,
);
tpl_register_option ( $tpl_option_array );
$tpl_option_array = array (
"name" => 'a_staff_single_image_size',
"title" => __( 'Image sizes on single member pages', 'a-staff' ),
"description" => __( 'Which image size should we use on the single member pages in the front end? (\'c\' at the end means that the image is cropped)', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'select',
"values" => $image_sizes,
"default" => 'a-staff-default',
"key" => true,
);
tpl_register_option ( $tpl_option_array );
// Boolean field: use legacy template?
$tpl_option_array = array (
"name" => 'a_staff_use_legacy_template',
"title" => __( 'Use Legacy box template', 'a-staff' ),
"description" => __( 'If enabled, the member tiles will be displayed using the Legacy Box template editor. If you are using a-staff v1.2 or newer, please use the Child Theme templates instead. Read more here', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'boolean',
"default" => false,
);
tpl_register_option ( $tpl_option_array );
// Textarea field: Member box template
$tpl_option_array = array (
"name" => 'a_staff_box_template',
"title" => __( 'Box template (Legacy)', 'a-staff' ),
"description" => __( 'Template editor for the member boxes. You can use the following shorttags in it:
{MEMBER_NAME} - Name of the Staff Member (the title of the article)
{MEMBER_EXCERPT} - Short bio of Staff Member (the excerpt of the article)
{MEMBER_TITLE} - Title of the Staff Member (Member Title taxonomy), will be separated by commas if there is more
{MEMBER_SOCICONS} - A list of the Staff Member\'s social links
{MEMBER_URL} - URL to the Staff Member\'s single page
{MEMBER_IMAGE} - URL to the Staff Member\'s featured image
{MEMBER_PHONE} - The Staff Member\'s phone number (if you enabled it on the Social tab)
IMPORTANT! This template editor will be deprecated in the next versions. Use the templating system introduced in v1.2 instead. Read more here
', 'a-staff' ),
"section" => 'a_staff_layout',
"type" => 'textarea',
"size" => 10,
"default" => '
', "after" => '', ), "condition" => array( array( "type" => 'option', "name" => 'a_staff_use_legacy_template', "relation" => '=', "value" => true, ), ), ); tpl_register_option ( $tpl_option_array ); // Select field: load the front end CSS or not $tpl_option_array = array ( "name" => 'a_staff_load_css', "title" => __( 'Load basic front end CSS?', 'a-staff' ), "description" => __( 'If enabled, a small CSS file will be loaded in the front end in order to give some shape to the Staff Member boxes.