Skip to content

Instantly share code, notes, and snippets.

@Damian96
Created March 20, 2022 12:21
Show Gist options
  • Save Damian96/adab9a565edb5edc636ed82f74c5c2ea to your computer and use it in GitHub Desktop.
Save Damian96/adab9a565edb5edc636ed82f74c5c2ea to your computer and use it in GitHub Desktop.
Redux Options Config for Theme
<?php
/*
The Redux Framework Options Configuration File.
Assigns to the global variable $theme_options all of the admin's options.
*/
if (!class_exists('Redux')) {
require_once ABSPATH . '\wp-content\plugins\redux-framework\redux-core\framework.php';
}
global $theme_options;
$opt_name = 'dg_custom';
// Uncomment to disable demo mode.
Redux::disable_demo();
// $theme = wp_get_theme(); // For use with some settings. Not necessary.
$args = array(
'display_name' => esc_html__( 'Ρυθμίσεις Θέματος', TEXT_DOMAIN ),
'display_version' => '1.0.0',
'menu_title' => esc_html__( 'Ρυθμίσεις Θέματος', TEXT_DOMAIN ),
'customizer' => false,
'dev_mode' => true
);
Redux::setArgs( $opt_name, $args );
$sections = array(
'basic',
);
Redux::setSection( $opt_name, array(
'title' => esc_html__( 'Βασικές Ρυθμίσεις', TEXT_DOMAIN ),
'id' => $sections[0],
'desc' => esc_html__( 'Social Media, Στοιχεία Επικοινωνίας', TEXT_DOMAIN ),
'icon' => 'el el-home',
'permissions' => 'delete_pages',
'fields' => array(
array(
'id' => 'facebook_url',
'type' => 'text',
'title' => esc_html__( 'Facebook', TEXT_DOMAIN ),
'desc' => esc_html__( 'Facebook Page URL', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'url',
'pattern' => 'https?://.*',
'required' => 'true'
)
// 'subtitle' => esc_html__( '', TEXT_DOMAIN ),
// 'hint' => array(
// 'content' => '',
// )
),
array(
'id' => 'instagram_url',
'type' => 'text',
'title' => esc_html__( 'Instagram', TEXT_DOMAIN ),
'desc' => esc_html__( 'Instagram Profile URL', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'url',
'pattern' => 'https?://.*',
'required' => 'true'
)
),
array(
'id' => 'twitter_url',
'type' => 'text',
'title' => esc_html__( 'Twitter', TEXT_DOMAIN ),
'desc' => esc_html__( 'Twitter Profile URL', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'url',
'pattern' => 'https?://.*',
'required' => 'true'
)
),
array(
'id' => 'youtube_url',
'type' => 'text',
'title' => esc_html__( 'Youtube', TEXT_DOMAIN ),
'desc' => esc_html__( 'Youtube Channel URL', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'url',
'pattern' => 'https?://.*',
'required' => 'true'
)
),
array(
'id' => 'address_full',
'type' => 'text',
'title' => esc_html__( 'Διεύθυνση', TEXT_DOMAIN ),
'desc' => esc_html__( 'π.χ. Αριστοτέλους 36, Εύοσμος, Θεσσαλονίκη, Ελλάδα TK 56224', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'text',
'minlength' => '10',
'required' => 'true'
)
),
array(
'id' => 'phone_1',
'type' => 'text',
'title' => esc_html__( 'Τηλέφωνο 1', TEXT_DOMAIN ),
'desc' => esc_html__( 'π.χ. +30 6980 123 456', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'text',
'pattern' => '[+\s0-9].*',
'minlength' => '10',
'required' => 'true'
)
),
array(
'id' => 'phone_2',
'type' => 'text',
'title' => esc_html__( 'Τηλέφωνο 2', TEXT_DOMAIN ),
'desc' => esc_html__( 'π.χ. +30 2310 123 456', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'text',
'pattern' => '[+\s0-9].*',
'minlength' => '10',
'required' => 'true'
)
),
array(
'id' => 'email_1',
'type' => 'text',
'title' => esc_html__( 'Email 1', TEXT_DOMAIN ),
'desc' => esc_html__( 'π.χ. [email protected]', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'email',
'required' => 'true'
)
),
array(
'id' => 'email_2',
'type' => 'text',
'title' => esc_html__( 'Email 2', TEXT_DOMAIN ),
'desc' => esc_html__( 'π.χ. [email protected]', TEXT_DOMAIN ),
'attributes' => array(
'type' => 'email',
'required' => 'true'
)
),
)
) );
$theme_options = get_option($opt_name);
add_action('redux/' . $opt_name . '/panel/after', function() {
$css = file_get_contents(get_template_directory() . '/assets/scss/redux-admin.min.css');
if (!empty($css)) {
echo '<style type="text/css">';
echo $css;
echo '</style>';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment