Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create title setting field type option #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/class.settings-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ function add_section( $section ) {
* @param array $fields settings fields array
*/
function set_fields( $fields ) {
foreach ( $fields as $section => $field ) {
foreach ( $field as $key => $option ) {
if ( $option['type'] == 'title' ) {
$fields[ $section ][ $key ]['class'] = 'wedevs-title';
$fields[ $section ][ $key ]['name'] = '';
}
}
}
$this->settings_fields = $fields;

return $this;
}

Expand Down Expand Up @@ -127,7 +134,7 @@ function admin_init() {
$args = array(
'id' => $name,
'class' => isset( $option['class'] ) ? $option['class'] : $name,
'label_for' => "{$section}[{$name}]",
'label_for' => "wpuf-{$section}[{$name}]",
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
'name' => $label,
'section' => $section,
Expand Down Expand Up @@ -166,6 +173,19 @@ public function get_field_description( $args ) {

return $desc;
}

/**
* Displays a title field
*
* @version 1.0.0
* @since 1.0.0
*
* @param array $args settings field args
*/
function callback_title( $args ) {
$html = $this->get_field_description( $args );
echo $html;
}

/**
* Displays a text field for a settings field
Expand Down Expand Up @@ -619,6 +639,18 @@ function _style_fix() {
/** WordPress 3.8 Fix **/
.form-table th { padding: 20px 10px; }
#wpbody-content .metabox-holder { padding-top: 5px; }

/** For Title setting field **/
#wpbody-content .metabox-holder h2{ padding: 0 !important; }
.wedevs-title th {
color: #23282d;
}
.wedevs-title label{
font-size: 1.3em !important;
}
.wedevs-title * {
cursor: auto;
}
</style>
<?php
endif;
Expand Down