File: //var/www/lipovac/wp-content/themes/senior/lib/redux/redux-theme-options.php
<?php
if (!class_exists('Redux_Framework_Wheels_Config')) {
class Redux_Framework_Wheels_Config {
public $args = array();
public $sections = array();
public $theme;
public $ReduxFramework;
public function __construct() {
if (!class_exists('ReduxFramework')) {
return;
}
// This is needed. Bah WordPress bugs. ;)
if ( true == Redux_Helpers::isTheme(__FILE__) ) {
$this->initSettings();
} else {
add_action('plugins_loaded', array($this, 'initSettings'), 10);
}
}
public function initSettings() {
// Just for demo purposes. Not needed per say.
$this->theme = wp_get_theme();
// Set the default arguments
$this->setArguments();
// Create the sections and fields
$this->setSections();
if (!isset($this->args['opt_name'])) { // No errors please
return;
}
// If Redux is running as a plugin, this will remove the demo notice and links
add_action( 'redux/loaded', array( $this, 'remove_demo' ) );
// Compiler hook and demo CSS output.
// Above 10 is a priority, but 2 in necessary to include the dynamically generated CSS to be sent to the function.
add_filter('redux/options/'.$this->args['opt_name'].'/compiler', array( $this, 'compiler_action' ), 10, 3);
// Dynamically add a section. Can be also used to modify sections/fields
add_filter('redux/options/' . $this->args['opt_name'] . '/sections', array($this, 'dynamic_section'), 999);
$this->ReduxFramework = new ReduxFramework($this->sections, $this->args);
}
function compiler_action($options, $css, $changed_values) {
$upload_dir = wp_upload_dir();
$filename = $upload_dir['basedir'] . '/' . $this->args['opt_name'] . '_style.css';
$filename = apply_filters('wheels_redux_compiler_filename', $filename);
$filecontent = "/********* Compiled file/Do not edit *********/\n";
$filecontent .= $css;
// adding !important manually
if (isset($options['main-menu-sticky-logo-height'])) {
$filecontent .= '.wh-sticky-header .wh-logo img{height:' . $options['main-menu-sticky-logo-height']['height'] . ' !important;}';
}
// Comment hr color
if (isset($options['body-typography']) && isset($options['body-typography']['color'])) {
$filecontent .= '.comment-list .comment hr{border-top-color:' . $options['body-typography']['color'] . ';}';
}
if (is_writable($upload_dir['basedir'])) {
file_put_contents($filename, $filecontent);
// chmod($filename, 0644);
} else {
wp_die(__("It looks like your upload folder isn't writable, so PHP couldn't make any changes (CHMOD).", 'wheels'), __('Cannot write to file', 'wheels'), array('back_link' => true));
}
// $access_type = get_filesystem_method();
// if($access_type === 'direct') {
//
//
// $upload_dir = wp_upload_dir();
// $filename = $upload_dir['basedir'] . '/' . $this->args['opt_name'] . '_style.css';
// global $wp_filesystem;
// if( empty( $wp_filesystem ) ) {
// require_once( ABSPATH .'/wp-admin/includes/file.php' );
// WP_Filesystem();
// }
//
// $filecontent = "/********* Compiled file/Do not edit *********/\n";
// $filecontent .= $css;
//
// if( $wp_filesystem ) {
// $wp_filesystem->put_contents(
// $filename,
// $filecontent,
// FS_CHMOD_FILE // predefined mode settings for WP files
// );
// }
// } else {
//
// /* don't have direct write access. Prompt user with our notice */
// add_action( 'admin_notices' , array( $this , 'admin_notice_permission_error' ), 999 );
// }
}
function admin_notice_permission_error() {
?>
<div class="error">
<h2><?php _e('Warrning', 'wheels') ?></h2>
<p><?php _e( 'You don\'t have permission to write directly to uploads folder.', 'wheels' ); ?></p>
<p><?php _e( 'This theme writes most of the CSS settings into a file to make the site load faster. You need to ...', 'wheels' ); ?></p>
</div>
<?php
}
/**
Custom function for filtering the sections array. Good for child themes to override or add to the sections.
Simply include this function in the child themes functions.php file.
NOTE: the defined constants for URLs, and directories will NOT be available at this point in a child theme,
so you must use get_template_directory_uri() if you want to use any of the built in icons
* */
function dynamic_section($sections) {
$sections[] = array(
'title' => __('Import / Export', 'redux-framework-demo'),
'desc' => __('Import and Export your Redux Framework settings from file, text or URL.', 'redux-framework-demo'),
'icon' => 'el-icon-refresh',
'fields' => array(
array(
'id' => 'opt-import-export',
'type' => 'import_export',
'title' => 'Import Export',
'subtitle' => 'Save and restore your Redux options',
'full_width' => false,
),
),
);
return $sections;
}
// Remove the demo link and the notice of integrated demo from the redux-framework plugin
function remove_demo() {
// Used to hide the demo mode link from the plugin page. Only used when Redux is a plugin.
if (class_exists('ReduxFrameworkPlugin')) {
remove_filter('plugin_row_meta', array(ReduxFrameworkPlugin::instance(), 'plugin_metalinks'), null, 2);
// Used to hide the activation notice informing users of the demo panel. Only used when Redux is a plugin.
remove_action('admin_notices', array(ReduxFrameworkPlugin::instance(), 'admin_notices'));
}
}
public function setSections() {
// DECLARATION OF SECTIONS
include_once dirname(__FILE__) . '/options.php';
}
public function setHelpTabs() {
// Custom page help tabs, displayed using the help API. Tabs are shown in order of definition.
$this->args['help_tabs'][] = array(
'id' => 'redux-help-tab-1',
'title' => __('Theme Information 1', 'redux-framework-demo'),
'content' => __('<p>This is the tab content, HTML is allowed.</p>', 'redux-framework-demo')
);
$this->args['help_tabs'][] = array(
'id' => 'redux-help-tab-2',
'title' => __('Theme Information 2', 'redux-framework-demo'),
'content' => __('<p>This is the tab content, HTML is allowed.</p>', 'redux-framework-demo')
);
// Set the help sidebar
$this->args['help_sidebar'] = __('<p>This is the sidebar content, HTML is allowed.</p>', 'redux-framework-demo');
}
/**
All the possible arguments for Redux.
For full documentation on arguments, please refer to: https://github.com/ReduxFramework/ReduxFramework/wiki/Arguments
* */
public function setArguments() {
$theme = wp_get_theme(); // For use with some settings. Not necessary.
$this->args = array(
// TYPICAL -> Change these values as you need/desire
'opt_name' => WHEELS_THEME_OPTION_NAME, // This is where your data is stored in the database and also becomes your global variable name.
'display_name' => $theme->get('Name'), // Name that appears at the top of your panel
'display_version' => '', // Version that appears at the top of your panel
'menu_type' => 'menu', //Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)
'allow_sub_menu' => true, // Show the sections below the admin menu item or not
'menu_title' => __('Theme Options', 'wheels'),
'page_title' => __('Theme Options', 'wheels'),
// You will need to generate a Google API key to use this feature.
// Please visit: https://developers.google.com/fonts/docs/developer_api#Auth
'google_api_key' => 'AIzaSyBETK1Pd_dt2PYIGteFgKS25rp6MmQFErw', // Must be defined to add google fonts to the typography module
'async_typography' => false, // Use a asynchronous font on the front end or font string
'admin_bar' => true, // Show the panel pages on the admin bar
'global_variable' => '', // Set a different name for your global variable other than the opt_name
'dev_mode' => false, // Show the time the page took to load, etc
'customizer' => true, // Enable basic customizer support
//'open_expanded' => true, // Allow you to start the panel in an expanded way initially.
//'disable_save_warn' => true, // Disable the save warning when a user changes a field
// OPTIONAL -> Give you extra features
'page_priority' => null, // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning.
'page_parent' => 'themes.php', // For a full list of options, visit: http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters
'page_permissions' => 'manage_options', // Permissions needed to access the options panel.
'menu_icon' => '', // Specify a custom URL to an icon
'last_tab' => '', // Force your panel to always open to a specific tab (by id)
'page_icon' => 'icon-themes', // Icon displayed in the admin panel next to your menu_title
'page_slug' => '_options', // Page slug used to denote the panel
'save_defaults' => true, // On load save the defaults to DB before user clicks save or not
'default_show' => false, // If true, shows the default value next to each field that is not the default value.
'default_mark' => '*', // What to print by the field's title if the value shown is default. Suggested: *
'show_import_export' => true, // Shows the Import/Export panel when not used as a field.
// CAREFUL -> These options are for advanced use only
'transient_time' => 60 * MINUTE_IN_SECONDS,
'output' => true, // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output
'output_tag' => true, // Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head
// 'footer_credit' => '', // Disable the footer credit of Redux. Please leave if you can help it.
// FUTURE -> Not in use yet, but reserved or partially implemented. Use at your own risk.
'database' => '', // possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning!
'system_info' => false, // REMOVE
// HINTS
'hints' => array(
'icon' => 'icon-question-sign',
'icon_position' => 'right',
'icon_color' => 'lightgray',
'icon_size' => 'normal',
'tip_style' => array(
'color' => 'light',
'shadow' => true,
'rounded' => false,
'style' => '',
),
'tip_position' => array(
'my' => 'top left',
'at' => 'bottom right',
),
'tip_effect' => array(
'show' => array(
'effect' => 'slide',
'duration' => '500',
'event' => 'mouseover',
),
'hide' => array(
'effect' => 'slide',
'duration' => '500',
'event' => 'click mouseleave',
),
),
)
);
// Add content before the form.
// $this->args['intro_text'] = __('<p>This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.</p>', 'redux-framework-demo');
// Add content after the form.
// $this->args['footer_text'] = __('<p>This text is displayed below the options panel. It isn\'t required, but more info is always better! The footer_text field accepts all HTML.</p>', 'redux-framework-demo');
}
}
global $reduxConfig;
$reduxConfig = new Redux_Framework_Wheels_Config();
}