Initial commit: Atomaste website

This commit is contained in:
2025-12-10 12:17:30 -05:00
commit 0b9e5d1605
19260 changed files with 5206382 additions and 0 deletions

View File

@@ -0,0 +1,763 @@
<?php
/**
* Download webfonts locally.
*
* @package wptt/font-loader
* @license https://opensource.org/licenses/MIT
*/
if ( ! class_exists( 'Rara_Business_WebFont_Loader' ) ) {
/**
* Download webfonts locally.
*/
class Rara_Business_WebFont_Loader {
/**
* The font-format.
*
* Use "woff" or "woff2".
* This will change the user-agent user to make the request.
*
* @access protected
* @since 1.0.0
* @var string
*/
protected $font_format = 'woff2';
/**
* The remote URL.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $remote_url;
/**
* Base path.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $base_path;
/**
* Base URL.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $base_url;
/**
* Subfolder name.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $subfolder_name;
/**
* The fonts folder.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $fonts_folder;
/**
* The local stylesheet's path.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $local_stylesheet_path;
/**
* The local stylesheet's URL.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $local_stylesheet_url;
/**
* The remote CSS.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $remote_styles;
/**
* The final CSS.
*
* @access protected
* @since 1.1.0
* @var string
*/
protected $css;
/**
* Cleanup routine frequency.
*/
const CLEANUP_FREQUENCY = 'monthly';
/**
* Constructor.
*
* Get a new instance of the object for a new URL.
*
* @access public
* @since 1.1.0
* @param string $url The remote URL.
*/
public function __construct( $url = '' ) {
$this->remote_url = $url;
// Add a cleanup routine.
$this->schedule_cleanup();
add_action( 'delete_fonts_folder', array( $this, 'delete_fonts_folder' ) );
}
/**
* Get the local URL which contains the styles.
*
* Fallback to the remote URL if we were unable to write the file locally.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_url() {
// Check if the local stylesheet exists.
if ( $this->local_file_exists() ) {
// Attempt to update the stylesheet. Return the local URL on success.
if ( $this->write_stylesheet() ) {
return $this->get_local_stylesheet_url();
}
}
// If the local file exists, return its URL, with a fallback to the remote URL.
return file_exists( $this->get_local_stylesheet_path() )
? $this->get_local_stylesheet_url()
: $this->remote_url;
}
/**
* Get the local stylesheet URL.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_local_stylesheet_url() {
if ( ! $this->local_stylesheet_url ) {
$this->local_stylesheet_url = str_replace(
$this->get_base_path(),
$this->get_base_url(),
$this->get_local_stylesheet_path()
);
}
return $this->local_stylesheet_url;
}
/**
* Get styles with fonts downloaded locally.
*
* @access public
* @since 1.0.0
* @return string
*/
public function get_styles() {
// If we already have the local file, return its contents.
$local_stylesheet_contents = $this->get_local_stylesheet_contents();
if ( $local_stylesheet_contents ) {
return $local_stylesheet_contents;
}
// Get the remote URL contents.
$this->remote_styles = $this->get_remote_url_contents();
// Get an array of locally-hosted files.
$files = $this->get_local_files_from_css();
// Convert paths to URLs.
foreach ( $files as $remote => $local ) {
$files[ $remote ] = str_replace(
$this->get_base_path(),
$this->get_base_url(),
$local
);
}
$this->css = str_replace(
array_keys( $files ),
array_values( $files ),
$this->remote_styles
);
$this->write_stylesheet();
return $this->css;
}
/**
* Get local stylesheet contents.
*
* @access public
* @since 1.1.0
* @return string|false Returns the remote URL contents.
*/
public function get_local_stylesheet_contents() {
$local_path = $this->get_local_stylesheet_path();
// Check if the local stylesheet exists.
if ( $this->local_file_exists() ) {
// Attempt to update the stylesheet. Return false on fail.
if ( ! $this->write_stylesheet() ) {
return false;
}
}
ob_start();
include $local_path;
return ob_get_clean();
}
/**
* Get remote file contents.
*
* @access public
* @since 1.0.0
* @return string Returns the remote URL contents.
*/
public function get_remote_url_contents() {
/**
* The user-agent we want to use.
*
* The default user-agent is the only one compatible with woff (not woff2)
* which also supports unicode ranges.
*/
$user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8';
// Switch to a user-agent supporting woff2 if we don't need to support IE.
if ( 'woff2' === $this->font_format ) {
$user_agent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0';
}
// Get the response.
$response = wp_remote_get( $this->remote_url, array( 'user-agent' => $user_agent ) );
// Early exit if there was an error.
if ( is_wp_error( $response ) ) {
return '';
}
// Get the CSS from our response.
$contents = wp_remote_retrieve_body( $response );
return $contents;
}
/**
* Download files mentioned in our CSS locally.
*
* @access public
* @since 1.0.0
* @return array Returns an array of remote URLs and their local counterparts.
*/
public function get_local_files_from_css() {
$font_files = $this->get_remote_files_from_css();
$stored = get_site_option( 'downloaded_font_files', array() );
$change = false; // If in the end this is true, we need to update the cache option.
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
}
// If the fonts folder don't exist, create it.
if ( ! file_exists( $this->get_fonts_folder() ) ) {
$this->get_filesystem()->mkdir( $this->get_fonts_folder(), FS_CHMOD_DIR );
}
foreach ( $font_files as $font_family => $files ) {
// The folder path for this font-family.
$folder_path = $this->get_fonts_folder() . '/' . $font_family;
// If the folder doesn't exist, create it.
if ( ! file_exists( $folder_path ) ) {
$this->get_filesystem()->mkdir( $folder_path, FS_CHMOD_DIR );
}
foreach ( $files as $url ) {
// Get the filename.
$filename = basename( wp_parse_url( $url, PHP_URL_PATH ) );
$font_path = $folder_path . '/' . $filename;
// Check if the file already exists.
if ( file_exists( $font_path ) ) {
// Skip if already cached.
if ( isset( $stored[ $url ] ) ) {
continue;
}
// Add file to the cache and change the $changed var to indicate we need to update the option.
$stored[ $url ] = $font_path;
$change = true;
// Since the file exists we don't need to proceed with downloading it.
continue;
}
/**
* If we got this far, we need to download the file.
*/
// require file.php if the download_url function doesn't exist.
if ( ! function_exists( 'download_url' ) ) {
require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
}
// Download file to temporary location.
$tmp_path = download_url( $url );
// Make sure there were no errors.
if ( is_wp_error( $tmp_path ) ) {
continue;
}
// Move temp file to final destination.
$success = $this->get_filesystem()->move( $tmp_path, $font_path, true );
if ( $success ) {
$stored[ $url ] = $font_path;
$change = true;
}
}
}
// If there were changes, update the option.
if ( $change ) {
// Cleanup the option and then save it.
foreach ( $stored as $url => $path ) {
if ( ! file_exists( $path ) ) {
unset( $stored[ $url ] );
}
}
update_site_option( 'downloaded_font_files', $stored );
}
return $stored;
}
/**
* Get font files from the CSS.
*
* @access public
* @since 1.0.0
* @return array Returns an array of font-families and the font-files used.
*/
public function get_remote_files_from_css() {
$font_faces = explode( '@font-face', $this->remote_styles );
$result = array();
// Loop all our font-face declarations.
foreach ( $font_faces as $font_face ) {
// Make sure we only process styles inside this declaration.
$style = explode( '}', $font_face )[0];
// Sanity check.
if ( false === strpos( $style, 'font-family' ) ) {
continue;
}
// Get an array of our font-families.
preg_match_all( '/font-family.*?\;/', $style, $matched_font_families );
// Get an array of our font-files.
preg_match_all( '/url\(.*?\)/i', $style, $matched_font_files );
// Get the font-family name.
$font_family = 'unknown';
if ( isset( $matched_font_families[0] ) && isset( $matched_font_families[0][0] ) ) {
$font_family = rtrim( ltrim( $matched_font_families[0][0], 'font-family:' ), ';' );
$font_family = trim( str_replace( array( "'", ';' ), '', $font_family ) );
$font_family = sanitize_key( strtolower( str_replace( ' ', '-', $font_family ) ) );
}
// Make sure the font-family is set in our array.
if ( ! isset( $result[ $font_family ] ) ) {
$result[ $font_family ] = array();
}
// Get files for this font-family and add them to the array.
foreach ( $matched_font_files as $match ) {
// Sanity check.
if ( ! isset( $match[0] ) ) {
continue;
}
// Add the file URL.
$font_family_url = rtrim( ltrim( $match[0], 'url(' ), ')' );
// Make sure to convert relative URLs to absolute.
$font_family_url = $this->get_absolute_path( $font_family_url );
$result[ $font_family ][] = $font_family_url;
}
// Make sure we have unique items.
// We're using array_flip here instead of array_unique for improved performance.
$result[ $font_family ] = array_flip( array_flip( $result[ $font_family ] ) );
}
return $result;
}
/**
* Write the CSS to the filesystem.
*
* @access protected
* @since 1.1.0
* @return string|false Returns the absolute path of the file on success, or false on fail.
*/
protected function write_stylesheet() {
$file_path = $this->get_local_stylesheet_path();
$filesystem = $this->get_filesystem();
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
}
// If the folder doesn't exist, create it.
if ( ! file_exists( $this->get_fonts_folder() ) ) {
$this->get_filesystem()->mkdir( $this->get_fonts_folder(), FS_CHMOD_DIR );
}
// If the file doesn't exist, create it. Return false if it can not be created.
if ( ! $filesystem->exists( $file_path ) && ! $filesystem->touch( $file_path ) ) {
return false;
}
// If we got this far, we need to write the file.
// Get the CSS.
if ( ! $this->css ) {
$this->get_styles();
}
// Put the contents in the file. Return false if that fails.
if ( ! $filesystem->put_contents( $file_path, $this->css ) ) {
return false;
}
return $file_path;
}
/**
* Get the stylesheet path.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_local_stylesheet_path() {
if ( ! $this->local_stylesheet_path ) {
$this->local_stylesheet_path = $this->get_fonts_folder() . '/' . $this->get_local_stylesheet_filename() . '.css';
}
return $this->local_stylesheet_path;
}
/**
* Get the local stylesheet filename.
*
* This is a hash, generated from the site-URL, the wp-content path and the URL.
* This way we can avoid issues with sites changing their URL, or the wp-content path etc.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_local_stylesheet_filename() {
return md5( $this->get_base_url() . $this->get_base_path() . $this->remote_url . $this->font_format );
}
/**
* Set the font-format to be used.
*
* @access public
* @since 1.0.0
* @param string $format The format to be used. Use "woff" or "woff2".
* @return void
*/
public function set_font_format( $format = 'woff2' ) {
$this->font_format = $format;
}
/**
* Get the font files and preload them.
*
* @access public
*/
public function preload_local_fonts() {
// Make sure variables are set.
// Get the remote URL contents.
$styles = $this->get_styles();
// Get an array of locally-hosted files.
$local_font = array();
$font_files = $this->get_remote_files_from_css( $styles );
foreach ( $font_files as $font_family => $files ) {
if ( is_array( $files ) ) {
$local_font[] = end( $files );
}
}
// Caching this for further optimization.
update_site_option( 'rara_business_local_font_files', $local_font );
foreach ( $local_font as $key => $local_font ) {
if ( $local_font ) {
echo '<link rel="preload" href="' . esc_url( $local_font ) . '" as="font" type="font/' . esc_attr( $this->font_format ) . '" crossorigin>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
/**
* Check if the local stylesheet exists.
*
* @access public
* @since 1.1.0
* @return bool
*/
public function local_file_exists() {
return ( ! file_exists( $this->get_local_stylesheet_path() ) );
}
/**
* Get the base path.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_base_path() {
if ( ! $this->base_path ) {
$this->base_path = apply_filters( 'rara_business_get_local_fonts_base_path', $this->get_filesystem()->wp_content_dir() );
}
return $this->base_path;
}
/**
* Get the base URL.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_base_url() {
if ( ! $this->base_url ) {
$this->base_url = apply_filters( 'rara_business_get_local_fonts_base_url', content_url() );
}
return $this->base_url;
}
/**
* Get the subfolder name.
*
* @access public
* @since 1.1.0
* @return string
*/
public function get_subfolder_name() {
if ( ! $this->subfolder_name ) {
$this->subfolder_name = apply_filters( 'rara_business_get_local_fonts_subfolder_name', 'fonts' );
}
return $this->subfolder_name;
}
/**
* Get the folder for fonts.
*
* @access public
* @return string
*/
public function get_fonts_folder() {
if ( ! $this->fonts_folder ) {
$this->fonts_folder = $this->get_base_path();
if ( $this->get_subfolder_name() ) {
$this->fonts_folder .= '/' . $this->get_subfolder_name();
}
}
return $this->fonts_folder;
}
/**
* Get the file preloads.
*
* @param string $url
* @param string $format
*/
public function load_preload_local_fonts( $url, $format = 'woff2' ) {
// Check if cache font files present or not
$local_font_files = get_site_option( 'rara_business_local_font_files', false );
if ( is_array( $local_font_files ) && ! empty( $local_font_files ) ) {
$font_format = apply_filters( 'rara_business_local_google_fonts_format', $format );
foreach ( $local_font_files as $key => $local_font ) {
if ( $local_font ) {
echo '<link rel="preload" href="' . esc_url( $local_font ) . '" as="font" type="font/' . esc_attr( $font_format ) . '" crossorigin>';
}
}
return;
}
// Now preload font data after processing it, as we didn't get stored data.
$font = rara_business_webfont_loader_instance( $url );
$this->set_font_format( $format );
$this->preload_local_fonts();
}
/**
* Schedule a cleanup.
*
* Deletes the fonts files on a regular basis.
* This way font files will get updated regularly,
* and we avoid edge cases where unused files remain in the server.
*
* @access public
* @since 1.1.0
* @return void
*/
public function schedule_cleanup() {
if ( ! is_multisite() || ( is_multisite() && is_main_site() ) ) {
if ( ! wp_next_scheduled( 'delete_fonts_folder' ) && ! wp_installing() ) {
wp_schedule_event( time(), self::CLEANUP_FREQUENCY, 'delete_fonts_folder' );
}
}
}
/**
* Delete the fonts folder.
*
* This runs as part of a cleanup routine.
*
* @access public
* @since 1.1.0
* @return bool
*/
public function delete_fonts_folder() {
//deleting site option for the theme
delete_site_option( 'rara_business_local_font_files' );
return $this->get_filesystem()->delete( $this->get_fonts_folder(), true );
}
/**
* Get the filesystem.
*
* @access protected
* @since 1.0.0
* @return \WP_Filesystem_Base
*/
protected function get_filesystem() {
global $wp_filesystem;
// If the filesystem has not been instantiated yet, do it here.
if ( ! $wp_filesystem ) {
if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
}
WP_Filesystem();
}
return $wp_filesystem;
}
/**
* Get an absolute URL from a relative URL.
*
* @access protected
*
* @param string $url The URL.
*
* @return string
*/
protected function get_absolute_path( $url ) {
// If dealing with a root-relative URL.
if ( 0 === stripos( $url, '/' ) ) {
$parsed_url = parse_url( $this->remote_url );
return $parsed_url['scheme'] . '://' . $parsed_url['hostname'] . $url;
}
return $url;
}
}
}
if ( ! function_exists( 'rara_business_get_webfont_styles' ) ) {
/**
* Get styles for a webfont.
*
* This will get the CSS from the remote API,
* download any fonts it contains,
* replace references to remote URLs with locally-downloaded assets,
* and finally return the resulting CSS.
*
* @since 1.0.0
*
* @param string $url The URL of the remote webfont.
* @param string $format The font-format. If you need to support IE, change this to "woff".
*
* @return string Returns the CSS.
*/
function rara_business_get_webfont_styles( $url, $format = 'woff2' ) {
$font = new Rara_Business_WebFont_Loader( $url );
$font->set_font_format( $format );
return $font->get_styles();
}
}
if ( ! function_exists( 'rara_business_get_webfont_url' ) ) {
/**
* Get a stylesheet URL for a webfont.
*
* @since 1.1.0
*
* @param string $url The URL of the remote webfont.
* @param string $format The font-format. If you need to support IE, change this to "woff".
*
* @return string Returns the CSS.
*/
function rara_business_get_webfont_url( $url, $format = 'woff2' ) {
$font = new Rara_Business_WebFont_Loader( $url );
$font->set_font_format( $format );
return $font->get_url();
}
}
/**
* Create instance of Rara_Business_WebFont_Loader class.
*/
function rara_business_webfont_loader_instance( $font_url = '' ) {
return new Rara_Business_WebFont_Loader( $font_url );
}

View File

@@ -0,0 +1,12 @@
/** Admin Notice */
.notice-info .notice-text {
position: relative;
}
.notice-text p.dismiss-link {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
}

View File

@@ -0,0 +1,81 @@
/*User stick note*/
h3.sticky_title {
margin-top: 12px;
margin-bottom: 11px;
}
span.sticky_info_row {
display: block;
line-height: 23px;
}
label.row-element {
font-weight: bold;
}
label.row-element.more-detail{
color: #ff0000;
}
.customize-text_editor{
font-size: 16px;
font-weight: bold;
}
.customize-text_editor_desc a {
background-color: #0089BD;
padding: 4px;
color: #fff;
border-radius: 7px;
margin: 2px 0;
display: inline-block;
transition:all ease 0.3s;
-webkit-transition:all ease 0.3s;
-moz-transition:all ease 0.3s;
}
.customize-text_editor_desc a:hover {
background-color: #fff;
color: #0089BD;
}
.customize-text_editor_desc .download-link{
display: block;
}
.customize-text_editor_desc span {
padding: 2px;
margin: 0;
display: inline-block;
}
.customize-text_editor_desc .upgrade-pro{
color: #FFF !important;
font-size: 12px;
line-height: 1;
text-align: center;
width: 90%;
margin-top: 10px;
}
#accordion-section-theme_info{
color: #0089BD;
}
.control-section-pro-section .accordion-section-title .button {
margin-top: -4px;
font-weight: 700;
margin-left: 8px;
background: #f89300;
color: #fff;
border-color: #f89300;
padding: 0 20px 1px;
}
.control-section-pro-section .accordion-section-title .button:hover,
.control-section-pro-section .accordion-section-title .button:focus{
background: #dc8200;
border-color: #dc8200;
}
.rtl .control-section-pro-section .accordion-section-title .button {
margin-left: 0;
margin-right: 8px;
}

View File

@@ -0,0 +1,24 @@
<?php
if( ! function_exists( 'rara_business_register_custom_controls' ) ) :
/**
* Register Custom Controls
*/
function rara_business_register_custom_controls( $wp_customize ){
// Load our custom control.
require_once get_template_directory() . '/inc/custom-controls/note/class-note-control.php';
require_once get_template_directory() . '/inc/custom-controls/radioimg/class-radio-image-control.php';
require_once get_template_directory() . '/inc/custom-controls/select/class-select-control.php';
require_once get_template_directory() . '/inc/custom-controls/slider/class-slider-control.php';
require_once get_template_directory() . '/inc/custom-controls/toggle/class-toggle-control.php';
require_once get_template_directory() . '/inc/custom-controls/repeater/class-repeater-setting.php';
require_once get_template_directory() . '/inc/custom-controls/repeater/class-control-repeater.php';
// Register the control type.
$wp_customize->register_control_type( 'Rara_Business_Radio_Image_Control' );
$wp_customize->register_control_type( 'Rara_Business_Select_Control' );
$wp_customize->register_control_type( 'Rara_Business_Slider_Control' );
$wp_customize->register_control_type( 'Rara_Business_Toggle_Control' );
}
endif;
add_action( 'customize_register', 'rara_business_register_custom_controls' );

View File

@@ -0,0 +1,27 @@
<?php
/**
* Customizer Control: Note.
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Note_Control' ) ) {
class Rara_Business_Note_Control extends WP_Customize_Control {
public function render_content(){ ?>
<span class="customize-control-title">
<?php echo esc_html( $this->label ); ?>
</span>
<?php if( $this->description ){ ?>
<span class="description customize-control-description">
<?php echo wp_kses_post($this->description); ?>
</span>
<?php }
}
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Customizer Control: radio-image.
*
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Radio_Image_Control' ) ) {
/**
* Radio Image control (modified radio).
*/
class Rara_Business_Radio_Image_Control extends WP_Customize_Control {
public $type = 'radio-image';
public $tooltip = '';
public function to_json() {
parent::to_json();
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
} else {
$this->json['default'] = $this->setting->default;
}
$this->json['value'] = $this->value();
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['tooltip'] = $this->tooltip;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
public function enqueue() {
wp_enqueue_style( 'rara-business-radio-image', get_template_directory_uri() . '/inc/custom-controls/radioimg/radio-image.css', null );
wp_enqueue_script( 'rara-business-radio-image', get_template_directory_uri() . '/inc/custom-controls/radioimg/radio-image.js', array( 'jquery' ), false, true ); //for radio-image
}
protected function content_template() {
?>
<# if ( data.tooltip ) { #>
<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
<# } #>
<label class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</label>
<div id="input_{{ data.id }}" class="image">
<# for ( key in data.choices ) { #>
<input {{{ data.inputAttrs }}} class="image-select" type="radio" value="{{ key }}" name="_customize-radio-{{ data.id }}" id="{{ data.id }}{{ key }}" {{{ data.link }}}<# if ( data.value === key ) { #> checked="checked"<# } #>>
<label for="{{ data.id }}{{ key }}">
<img src="{{ data.choices[ key ] }}">
<span class="image-clickable"></span>
</label>
</input>
<# } #>
</div>
<?php
}
}
}

View File

@@ -0,0 +1,26 @@
/*Radio Image Button */
.customize-control-radio-image label {
position: relative;
display: inline-block;
margin-bottom: 10px;
}
.customize-control-radio-image input {
display: none;
}
.customize-control-radio-image input img {
border: 1px solid transparent;
}
.customize-control-radio-image input:checked + label img {
-webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.25);
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.25);
border: 1px solid #3498DB;
}
.customize-control-radio-image input + label .image-clickable {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
}
/*Radio Image Button Ends */

View File

@@ -0,0 +1,16 @@
wp.customize.controlConstructor['radio-image'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this;
// Change the value
this.container.on( 'click', 'input', function() {
control.setting.set( jQuery( this ).val() );
});
}
});

View File

@@ -0,0 +1,508 @@
<?php
/**
* Rara Business Customizer Repeater Control.
*
* @package Rara_Business
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if( ! class_exists( 'Rara_Business_Control_Repeater' ) ) {
/**
* Repeater control
*/
class Rara_Business_Control_Repeater extends WP_Customize_Control {
/**
* The control type.
*
* @access public
* @var string
*/
public $type = 'rara-business-repeater';
/**
* Data type
*
* @access public
* @var string
*/
public $option_type = 'theme_mod';
/**
* The fields that each container row will contain.
*
* @access public
* @var array
*/
public $fields = array();
/**
* Will store a filtered version of value for advenced fields (like images).
*
* @access protected
* @var array
*/
protected $filtered_value = array();
/**
* The row label
*
* @access public
* @var array
*/
public $row_label = array();
/**
* Constructor.
* Supplied `$args` override class property defaults.
* If `$args['settings']` is not defined, use the $id as the setting ID.
*
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id Control ID.
* @param array $args {@see WP_Customize_Control::__construct}.
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
// Set up defaults for row labels.
$this->row_label = array(
'type' => 'text',
'value' => esc_attr__( 'row', 'rara-business' ),
'field' => false,
);
// Validate row-labels.
$this->row_label( $args );
if ( empty( $this->button_label ) ) {
$this->button_label = sprintf( esc_attr__( 'Add new %s', 'rara-business' ), $this->row_label['value'] );
}
if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) {
$args['fields'] = array();
}
// An array to store keys of fields that need to be filtered.
$media_fields_to_filter = array();
foreach ( $args['fields'] as $key => $value ) {
$args['fields'][ $key ]['default'] = ( isset( $value['default'] ) ) ? $value['default'] : '';
$args['fields'][ $key ]['id'] = $key;
// We check if the filed is an uploaded media ( image , file, video, etc.. ).
if ( isset( $value['type'] ) ) {
switch ( $value['type'] ) {
case 'image':
case 'cropped_image':
case 'upload':
// We add it to the list of fields that need some extra filtering/processing.
$media_fields_to_filter[ $key ] = true;
break;
}
}
}
$this->fields = $args['fields'];
// Now we are going to filter the fields.
// First we create a copy of the value that would be used otherwise.
$this->filtered_value = $this->value();
if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
// We iterate over the list of fields.
foreach ( $this->filtered_value as &$filtered_value_field ) {
if ( is_array( $filtered_value_field ) && ! empty( $filtered_value_field ) ) {
// We iterate over the list of properties for this field.
foreach ( $filtered_value_field as $key => &$value ) {
// We check if this field was marked as requiring extra filtering (in this case image, cropped_images, upload).
if ( array_key_exists( $key, $media_fields_to_filter ) ) {
// What follows was made this way to preserve backward compatibility.
// The repeater control use to store the URL for images instead of the attachment ID.
// We check if the value look like an ID (otherwise it's probably a URL so don't filter it).
if ( is_numeric( $value ) ) {
// "sanitize" the value.
$attachment_id = (int) $value;
// Try to get the attachment_url.
$url = wp_get_attachment_url( $attachment_id );
$filename = basename( get_attached_file( $attachment_id ) );
// If we got a URL.
if ( $url ) {
// 'id' is needed for form hidden value, URL is needed to display the image.
$value = array(
'id' => $attachment_id,
'url' => $url,
'filename' => $filename,
);
}
}
}
}
}
}
}
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @access public
*/
public function to_json() {
parent::to_json();
$this->json['default'] = ( isset( $this->default ) ) ? $this->default : $this->setting->default;
$this->json['value'] = $this->value();
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
if ( 'user_meta' === $this->option_type ) {
$this->json['value'] = get_user_meta( get_current_user_id(), $this->id, true );
}
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
$fields = $this->fields;
$this->json['fields'] = $fields;
$this->json['row_label'] = $this->row_label;
// If filtered_value has been set and is not empty we use it instead of the actual value.
if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
$this->json['value'] = $this->filtered_value;
}
}
/**
* Enqueue control related scripts/styles.
*
* @access public
*/
public function enqueue() {
// If we have a color picker field we need to enqueue the WordPress Color Picker style and script.
if ( is_array( $this->fields ) && ! empty( $this->fields ) ) {
foreach ( $this->fields as $field ) {
if ( isset( $field['type'] ) ){
if( 'color' === $field['type'] ){
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
}elseif( 'font' === $field['type'] ){
wp_enqueue_script( 'all', get_template_directory_uri() . '/js/all.min.js', array( 'jquery' ), '6.1.1', true );
wp_enqueue_script( 'v4-shims', get_template_directory_uri() . '/js/v4-shims.min.js', array( 'jquery', 'all' ), '6.1.1', true );
}
}
}
}
wp_enqueue_script( 'rara-business-repeater', get_template_directory_uri() . '/inc/custom-controls/repeater/repeater.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), false, true );
wp_enqueue_style( 'rara-business-repeater', get_template_directory_uri() . '/inc/custom-controls/repeater/repeater.css', null );
}
/**
* Render the control's content.
* Allows the content to be overriden without having to rewrite the wrapper in $this->render().
*
* @access protected
*/
protected function render_content() {
?>
<label>
<?php if ( ! empty( $this->label ) ) : ?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php endif; ?>
<?php if ( ! empty( $this->description ) ) : ?>
<span class="description customize-control-description"><?php echo wp_kses_post( $this->description ); ?></span>
<?php endif; ?>
<input type="hidden" {{{ data.inputAttrs }}} value="" <?php echo wp_kses_post( $this->get_link() ); ?> />
</label>
<ul class="repeater-fields"></ul>
<?php if ( isset( $this->choices['limit'] ) ) : ?>
<p class="limit"><?php printf( esc_html__( 'Limit: %s rows', 'rara-business' ), esc_html( $this->choices['limit'] ) ); ?></p>
<?php endif; ?>
<button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button>
<?php
$this->repeater_js_template();
}
/**
* An Underscore (JS) template for this control's content (but not its container).
* Class variables for this control class are available in the `data` JS object.
*
* @access public
*/
public function repeater_js_template() {
?>
<script type="text/html" class="customize-control-repeater-content">
<# var field; var index = data.index; #>
<li class="repeater-row minimized" data-row="{{{ index }}}">
<div class="repeater-row-header">
<span class="repeater-row-label"></span>
<i class="dashicons dashicons-arrow-down repeater-minimize"></i>
</div>
<div class="repeater-row-content">
<# _.each( data, function( field, i ) { #>
<div class="repeater-field repeater-field-{{{ field.type }}}">
<# if ( 'text' === field.type || 'font' === field.type || 'url' === field.type || 'link' === field.type || 'email' === field.type || 'tel' === field.type || 'date' === field.type ) { #>
<# if ( 'link' === field.type ) { #>
<# field.type = 'url' #>
<# } #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<input type="{{field.type}}" name="" value="{{{ field.default }}}" data-field="{{{ field.id }}}">
</label>
<# } else if ( 'hidden' === field.type ) { #>
<input type="hidden" data-field="{{{ field.id }}}" <# if ( field.default ) { #> value="{{{ field.default }}}" <# } #> />
<# } else if ( 'checkbox' === field.type ) { #>
<label>
<input type="checkbox" value="true" data-field="{{{ field.id }}}" <# if ( field.default ) { #> checked="checked" <# } #> /> {{ field.label }}
<# if ( field.description ) { #>
{{ field.description }}
<# } #>
</label>
<# } else if ( 'select' === field.type ) { #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<select data-field="{{{ field.id }}}">
<# _.each( field.choices, function( choice, i ) { #>
<option value="{{{ i }}}" <# if ( field.default == i ) { #> selected="selected" <# } #>>{{ choice }}</option>
<# }); #>
</select>
</label>
<# } else if ( 'radio' === field.type ) { #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<# _.each( field.choices, function( choice, i ) { #>
<label>
<input type="radio" name="{{{ field.id }}}{{ index }}" data-field="{{{ field.id }}}" value="{{{ i }}}" <# if ( field.default == i ) { #> checked="checked" <# } #>> {{ choice }} <br/>
</label>
<# }); #>
</label>
<# } else if ( 'radio-image' === field.type ) { #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<# _.each( field.choices, function( choice, i ) { #>
<input type="radio" id="{{{ field.id }}}_{{ index }}_{{{ i }}}" name="{{{ field.id }}}{{ index }}" data-field="{{{ field.id }}}" value="{{{ i }}}" <# if ( field.default == i ) { #> checked="checked" <# } #>>
<label for="{{{ field.id }}}_{{ index }}_{{{ i }}}">
<img src="{{ choice }}">
</label>
</input>
<# }); #>
</label>
<# } else if ( 'color' === field.type ) { #>
<# var defaultValue = '';
if ( field.default ) {
if ( '#' !== field.default.substring( 0, 1 ) ) {
defaultValue = '#' + field.default;
} else {
defaultValue = field.default;
}
defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically.
} #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{{ field.label }}}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{{ field.description }}}</span>
<# } #>
<input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php echo esc_attr__( 'Hex Value', 'rara-business' ); ?>" value="{{{ field.default }}}" data-field="{{{ field.id }}}" {{ defaultValue }} />
</label>
<# } else if ( 'textarea' === field.type ) { #>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<textarea rows="5" data-field="{{{ field.id }}}">{{ field.default }}</textarea>
<# } else if ( field.type === 'image' || field.type === 'cropped_image' ) { #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
</label>
<figure class="rara-business-image-attachment" data-placeholder="<?php esc_attr_e( 'No Image Selected', 'rara-business' ); ?>" >
<# if ( field.default ) { #>
<# var defaultImageURL = ( field.default.url ) ? field.default.url : field.default; #>
<img src="{{{ defaultImageURL }}}">
<# } else { #>
<?php esc_attr_e( 'No Image Selected', 'rara-business' ); ?>
<# } #>
</figure>
<div class="actions">
<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"><?php esc_html_e( 'Remove', 'rara-business' ); ?></button>
<button type="button" class="button upload-button" data-label=" <?php esc_attr_e( 'Add Image', 'rara-business' ); ?>" data-alt-label="<?php esc_attr_e( 'Change Image', 'rara-business' ); ?>" >
<# if ( field.default ) { #>
<?php esc_attr_e( 'Change Image', 'rara-business' ); ?>
<# } else { #>
<?php esc_attr_e( 'Add Image', 'rara-business' ); ?>
<# } #>
</button>
<# if ( field.default.id ) { #>
<input type="hidden" class="hidden-field" value="{{{ field.default.id }}}" data-field="{{{ field.id }}}" >
<# } else { #>
<input type="hidden" class="hidden-field" value="{{{ field.default }}}" data-field="{{{ field.id }}}" >
<# } #>
</div>
<# } else if ( field.type === 'upload' ) { #>
<label>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
</label>
<figure class="rara-business-file-attachment" data-placeholder="<?php esc_attr_e( 'No File Selected', 'rara-business' ); ?>" >
<# if ( field.default ) { #>
<# var defaultFilename = ( field.default.filename ) ? field.default.filename : field.default; #>
<span class="file"><span class="dashicons dashicons-media-default"></span> {{ defaultFilename }}</span>
<# } else { #>
<?php esc_attr_e( 'No File Selected', 'rara-business' ); ?>
<# } #>
</figure>
<div class="actions">
<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"></button>
<button type="button" class="button upload-button" data-label="<?php esc_attr_e( 'Add File', 'rara-business' ); ?>" data-alt-label="<?php esc_attr_e( 'Change File', 'rara-business' ); ?>" >
<# if ( field.default ) { #>
<?php esc_attr_e( 'Change File', 'rara-business' ); ?>
<# } else { #>
<?php esc_attr_e( 'Add File', 'rara-business' ); ?>
<# } #>
</button>
<# if ( field.default.id ) { #>
<input type="hidden" class="hidden-field" value="{{{ field.default.id }}}" data-field="{{{ field.id }}}" >
<# } else { #>
<input type="hidden" class="hidden-field" value="{{{ field.default }}}" data-field="{{{ field.id }}}" >
<# } #>
</div>
<# } else if ( 'custom' === field.type ) { #>
<# if ( field.label ) { #>
<span class="customize-control-title">{{ field.label }}</span>
<# } #>
<# if ( field.description ) { #>
<span class="description customize-control-description">{{ field.description }}</span>
<# } #>
<div data-field="{{{ field.id }}}">{{{ field.default }}}</div>
<# } #>
</div>
<# }); #>
<button type="button" class="button-link repeater-row-remove"><?php esc_html_e( 'Remove', 'rara-business' ); ?></button>
</div>
</li>
</script>
<?php
}
/**
* Validate row-labels.
*
* @access protected
* @since 2.4.0
* @param array $args {@see WP_Customize_Control::__construct}.
*/
protected function row_label( $args ) {
// Validating args for row labels.
if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) {
// Validating row label type.
if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) {
$this->row_label['type'] = $args['row_label']['type'];
}
// Validating row label type.
if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) {
$this->row_label['value'] = esc_attr( $args['row_label']['value'] );
}
// Validating row label field.
if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) {
$this->row_label['field'] = esc_attr( $args['row_label']['field'] );
} else {
// If from field is not set correctly, making sure standard is set as the type.
$this->row_label['type'] = 'text';
}
}
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Rara Business Repeater Customizer Setting.
*
* @package Rara_Business
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Repeater_Setting' ) ) {
/**
* Repeater Settings.
*/
class Rara_Business_Repeater_Setting extends WP_Customize_Setting {
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @access public
* @param WP_Customize_Manager $manager The WordPress WP_Customize_Manager object.
* @param string $id A specific ID of the setting. Can be a theme mod or option name.
* @param array $args Setting arguments.
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
// Will onvert the setting from JSON to array. Must be triggered very soon.
add_filter( "customize_sanitize_{$this->id}", array( $this, 'sanitize_repeater_setting' ), 10, 1 );
}
/**
* Fetch the value of the setting.
*
* @access public
* @return mixed The value.
*/
public function value() {
$value = parent::value();
if ( ! is_array( $value ) ) {
$value = array();
}
return $value;
}
/**
* Convert the JSON encoded setting coming from Customizer to an Array.
*
* @access public
* @param string $value URL Encoded JSON Value.
* @return array
*/
public static function sanitize_repeater_setting( $value ){
if ( ! is_array( $value ) ) {
$value = json_decode( urldecode( $value ) );
}
$sanitized = ( empty( $value ) || ! is_array( $value ) ) ? array() : $value;
// Make sure that every row is an array, not an object.
foreach ( $sanitized as $key => $_value ) {
if ( empty( $_value ) ) {
unset( $sanitized[ $key ] );
} else {
$sanitized[ $key ] = (array) $_value;
}
}
// Reindex array.
$sanitized = array_values( $sanitized );
return $sanitized;
}
}
}

View File

@@ -0,0 +1,204 @@
.customize-control-rara-business-repeater .repeater-fields .repeater-row {
border: 1px solid #999;
margin-top: 0.5rem;
background: #eee;
position: relative;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row.minimized {
border: 1px solid #dfdfdf;
padding: 0;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row.minimized:hover {
border: 1px solid #999;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row.minimized .repeater-row-content {
display: none;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row label {
margin-bottom: 12px;
clear: both;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row .repeater-field.repeater-field- {
display: none;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row .repeater-field.repeater-field-radio-image input {
display: none;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row .repeater-field.repeater-field-radio-image input img {
border: 1px solid transparent;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row .repeater-field.repeater-field-radio-image input:checked + label img {
-webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.25);
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.25);
border: 1px solid #3498DB;
}
.customize-control-rara-business-repeater .repeater-fields .repeater-row .repeater-field:last-child {
border-bottom: none;
padding-bottom: 0;
}
.customize-control-rara-business-repeater button.repeater-add {
margin-top: 1rem;
}
.customize-control-rara-business-repeater .repeater-row-content {
padding: 10px 15px;
}
.customize-control-rara-business-repeater .repeater-field {
margin-bottom: 12px;
width: 100%;
clear: both;
padding-bottom: 12px;
border-bottom: 1px dotted #CCC;
}
.customize-control-rara-business-repeater .repeater-field .customize-control-title {
font-size: 13px;
line-height: initial;
}
.customize-control-rara-business-repeater .repeater-field .customize-control-description {
font-size: 13px;
line-height: initial;
}
.customize-control-rara-business-repeater .repeater-field.repeater-field-hidden {
margin: 0;
padding: 0;
border: 0;
}
.customize-control-rara-business-repeater .repeater-field-select select {
margin-left: 0;
}
.customize-control-rara-business-repeater .repeater-field-checkbox label {
line-height: 28px;
}
.customize-control-rara-business-repeater .repeater-field-checkbox input {
line-height: 28px;
margin-right: 5px;
}
.customize-control-rara-business-repeater .repeater-field-textarea textarea {
width: 100%;
resize: vertical;
}
.customize-control-rara-business-repeater .repeater-row-header {
background: white;
border: 1px solid #dfdfdf;
position: relative;
padding: 10px 15px;
height: auto;
min-height: 20px;
line-height: 30px;
overflow: hidden;
word-wrap: break-word;
}
.customize-control-rara-business-repeater .repeater-row-header:hover {
cursor: move;
}
.customize-control-rara-business-repeater .repeater-row-header .dashicons {
font-size: 18px;
position: absolute;
right: 12px;
top: 2px;
color: #a0a5aa;
}
.customize-control-rara-business-repeater .repeater-row-label {
font-size: 13px;
font-weight: 600;
line-height: 20px;
display: block;
width: 90%;
overflow: hidden;
height: 18px;
}
.customize-control-rara-business-repeater .repeater-row-remove {
color: #a00;
}
.customize-control-rara-business-repeater .repeater-row-remove:hover {
color: #f00;
}
.customize-control-rara-business-repeater .repeater-minimize {
line-height: 36px;
}
.customize-control-rara-business-repeater .remove-button,
.customize-control-rara-business-repeater .upload-button {
width: 48%;
}
.rara-business-image-attachment {
margin: 0;
text-align: center;
margin-bottom: 10px;
}
.rara-business-image-attachment img {
display: inline-block;
}
.rara-business-file-attachment {
margin: 0;
text-align: center;
margin-bottom: 10px;
}
.rara-business-file-attachment .file {
display: block;
padding: 10px 5px;
border: 1px dotted #c3c3c3;
background: #f9f9f9;
}
.limit {
padding: 3px;
border-radius: 3px;
}
.limit.highlight {
background: #D32F2F;
color: #fff;
}
/** Font awesome list */
.font-group{
text-align: center;
height: 350px;
overflow-y: scroll;
position: relative;
border: 1px solid #EEE;
margin: 0;
}
.font-group li{
width: 50px;
height: 50px;
display: inline-block;
margin: 4px;
cursor: pointer;
font-size: 25px;
}
input[type="font"]{
width: 100%;
border: 0;
}

View File

@@ -0,0 +1,860 @@
/*jshint -W065 */
var rarabusinessRepeaterRow = function( rowIndex, container, label ){
'use strict';
var self = this;
this.rowIndex = rowIndex;
this.container = container;
this.label = label;
this.header = this.container.find( '.repeater-row-header' ),
this.header.on( 'click', function() {
self.toggleMinimize();
});
this.container.on( 'click', '.repeater-row-remove', function() {
self.remove();
});
this.header.on( 'mousedown', function() {
self.container.trigger( 'row:start-dragging' );
});
this.container.on( 'keyup change', 'input, select, textarea', function( e ) {
self.container.trigger( 'row:update', [ self.rowIndex, jQuery( e.target ).data( 'field' ), e.target ] );
});
this.setRowIndex = function( rowIndex ) {
this.rowIndex = rowIndex;
this.container.attr( 'data-row', rowIndex );
this.container.data( 'row', rowIndex );
this.updateLabel();
};
this.toggleMinimize = function() {
// Store the previous state.
this.container.toggleClass( 'minimized' );
this.header.find( '.dashicons' ).toggleClass( 'dashicons-arrow-up' ).toggleClass( 'dashicons-arrow-down' );
};
this.remove = function() {
this.container.slideUp( 300, function() {
jQuery( this ).detach();
});
this.container.trigger( 'row:remove', [ this.rowIndex ] );
};
this.updateLabel = function() {
var rowLabelField,
rowLabel;
if ( 'field' === this.label.type ) {
rowLabelField = this.container.find( '.repeater-field [data-field="' + this.label.field + '"]' );
if ( 'function' === typeof rowLabelField.val ) {
rowLabel = rowLabelField.val();
if ( '' !== rowLabel ) {
this.header.find( '.repeater-row-label' ).text( rowLabel );
return;
}
}
}
this.header.find( '.repeater-row-label' ).text( this.label.value + ' ' + ( this.rowIndex + 1 ) );
};
this.updateLabel();
};
wp.customize.controlConstructor['rara-business-repeater'] = wp.customize.Control.extend({
ready: function(){
'use strict';
var control = this,
limit,
theNewRow;
// The current value set in Control Class (set in Rara_Business_Control_Repeater::to_json() function)
var settingValue = this.params.value;
// The hidden field that keeps the data saved (though we never update it)
this.settingField = this.container.find( '[data-customize-setting-link]' ).first();
// Set the field value for the first time, we'll fill it up later
this.setValue( [], false );
// The DIV that holds all the rows
this.repeaterFieldsContainer = this.container.find( '.repeater-fields' ).first();
// Set number of rows to 0
this.currentIndex = 0;
// Save the rows objects
this.rows = [];
// Default limit choice
limit = false;
if ( 'undefined' !== typeof this.params.choices.limit ) {
limit = ( 0 >= this.params.choices.limit ) ? false : parseInt( this.params.choices.limit );
}
this.container.on( 'click', 'button.repeater-add', function( e ) {
e.preventDefault();
if ( ! limit || control.currentIndex < limit ) {
theNewRow = control.addRow();
theNewRow.toggleMinimize();
control.initColorPicker();
//control.initDropdownPages( theNewRow );
} else {
jQuery( control.selector + ' .limit' ).addClass( 'highlight' );
}
});
this.container.on( 'click', '.repeater-row-remove', function( e ) {
control.currentIndex--;
if ( ! limit || control.currentIndex < limit ) {
jQuery( control.selector + ' .limit' ).removeClass( 'highlight' );
}
});
this.container.on( 'click keypress', '.repeater-field-image .upload-button,.repeater-field-cropped_image .upload-button,.repeater-field-upload .upload-button', function( e ) {
e.preventDefault();
control.$thisButton = jQuery( this );
control.openFrame( e );
});
this.container.on( 'click keypress', '.repeater-field-image .remove-button,.repeater-field-cropped_image .remove-button', function( e ) {
e.preventDefault();
control.$thisButton = jQuery( this );
control.removeImage( e );
});
this.container.on( 'click keypress', '.repeater-field-upload .remove-button', function( e ) {
e.preventDefault();
control.$thisButton = jQuery( this );
control.removeFile( e );
});
/**
* Function that loads the Mustache template
*/
this.repeaterTemplate = _.memoize( function() {
var compiled,
/*
* Underscore's default ERB-style templates are incompatible with PHP
* when asp_tags is enabled, so WordPress uses Mustache-inspired templating syntax.
*
* @see trac ticket #22344.
*/
options = {
evaluate: /<#([\s\S]+?)#>/g,
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
escape: /\{\{([^\}]+?)\}\}(?!\})/g,
variable: 'data'
};
return function( data ) {
compiled = _.template( control.container.find( '.customize-control-repeater-content' ).first().html(), null, options );
return compiled( data );
};
});
// When we load the control, the fields have not been filled up
// This is the first time that we create all the rows
if( settingValue.length ){
_.each( settingValue, function( subValue ) {
theNewRow = control.addRow( subValue );
control.initColorPicker();
//control.initDropdownPages( theNewRow, subValue );
});
}
// Once we have displayed the rows, we cleanup the values
this.setValue( settingValue, true, true );
this.repeaterFieldsContainer.sortable({
handle: '.repeater-row-header',
update: function( e, ui ) {
control.sort();
}
});
},
/**
* Open the media modal.
*/
openFrame: function( event ){
'use strict';
if ( wp.customize.utils.isKeydownButNotEnterEvent( event ) ) {
return;
}
if ( this.$thisButton.closest( '.repeater-field' ).hasClass( 'repeater-field-cropped_image' ) ) {
this.initCropperFrame();
} else {
this.initFrame();
}
this.frame.open();
},
initFrame: function(){
'use strict';
var libMediaType = this.getMimeType();
this.frame = wp.media({
states: [
new wp.media.controller.Library({
library: wp.media.query({ type: libMediaType }),
multiple: false,
date: false
})
]
});
// When a file is selected, run a callback.
this.frame.on( 'select', this.onSelect, this );
},
/**
* Create a media modal select frame, and store it so the instance can be reused when needed.
* This is mostly a copy/paste of Core api.CroppedImageControl in /wp-admin/js/customize-control.js
*/
initCropperFrame: function(){
'use strict';
// We get the field id from which this was called
var currentFieldId = this.$thisButton.siblings( 'input.hidden-field' ).attr( 'data-field' ),
attrs = [ 'width', 'height', 'flex_width', 'flex_height' ], // A list of attributes to look for
libMediaType = this.getMimeType();
// Make sure we got it
if ( 'string' === typeof currentFieldId && '' !== currentFieldId ) {
// Make fields is defined and only do the hack for cropped_image
if ( 'object' === typeof this.params.fields[ currentFieldId ] && 'cropped_image' === this.params.fields[ currentFieldId ].type ) {
//Iterate over the list of attributes
attrs.forEach( function( el, index ) {
// If the attribute exists in the field
if ( 'undefined' !== typeof this.params.fields[ currentFieldId ][ el ] ) {
// Set the attribute in the main object
this.params[ el ] = this.params.fields[ currentFieldId ][ el ];
}
}.bind( this ) );
}
}
this.frame = wp.media({
button: {
text: 'Select and Crop',
close: false
},
states: [
new wp.media.controller.Library({
library: wp.media.query({ type: libMediaType }),
multiple: false,
date: false,
suggestedWidth: this.params.width,
suggestedHeight: this.params.height
}),
new wp.media.controller.CustomizeImageCropper({
imgSelectOptions: this.calculateImageSelectOptions,
control: this
})
]
});
this.frame.on( 'select', this.onSelectForCrop, this );
this.frame.on( 'cropped', this.onCropped, this );
this.frame.on( 'skippedcrop', this.onSkippedCrop, this );
},
onSelect: function(){
'use strict';
var attachment = this.frame.state().get( 'selection' ).first().toJSON();
if ( this.$thisButton.closest( '.repeater-field' ).hasClass( 'repeater-field-upload' ) ) {
this.setFileInRepeaterField( attachment );
} else {
this.setImageInRepeaterField( attachment );
}
},
/**
* After an image is selected in the media modal, switch to the cropper
* state if the image isn't the right size.
*/
onSelectForCrop: function(){
'use strict';
var attachment = this.frame.state().get( 'selection' ).first().toJSON();
if ( this.params.width === attachment.width && this.params.height === attachment.height && ! this.params.flex_width && ! this.params.flex_height ) {
this.setImageInRepeaterField( attachment );
} else {
this.frame.setState( 'cropper' );
}
},
/**
* After the image has been cropped, apply the cropped image data to the setting.
*
* @param {object} croppedImage Cropped attachment data.
*/
onCropped: function( croppedImage ){
'use strict';
this.setImageInRepeaterField( croppedImage );
},
/**
* Returns a set of options, computed from the attached image data and
* control-specific data, to be fed to the imgAreaSelect plugin in
* wp.media.view.Cropper.
*
* @param {wp.media.model.Attachment} attachment
* @param {wp.media.controller.Cropper} controller
* @returns {Object} Options
*/
calculateImageSelectOptions: function( attachment, controller ){
'use strict';
var control = controller.get( 'control' ),
flexWidth = !! parseInt( control.params.flex_width, 10 ),
flexHeight = !! parseInt( control.params.flex_height, 10 ),
realWidth = attachment.get( 'width' ),
realHeight = attachment.get( 'height' ),
xInit = parseInt( control.params.width, 10 ),
yInit = parseInt( control.params.height, 10 ),
ratio = xInit / yInit,
xImg = realWidth,
yImg = realHeight,
x1,
y1,
imgSelectOptions;
controller.set( 'canSkipCrop', ! control.mustBeCropped( flexWidth, flexHeight, xInit, yInit, realWidth, realHeight ) );
if ( xImg / yImg > ratio ) {
yInit = yImg;
xInit = yInit * ratio;
} else {
xInit = xImg;
yInit = xInit / ratio;
}
x1 = ( xImg - xInit ) / 2;
y1 = ( yImg - yInit ) / 2;
imgSelectOptions = {
handles: true,
keys: true,
instance: true,
persistent: true,
imageWidth: realWidth,
imageHeight: realHeight,
x1: x1,
y1: y1,
x2: xInit + x1,
y2: yInit + y1
};
if ( false === flexHeight && false === flexWidth ) {
imgSelectOptions.aspectRatio = xInit + ':' + yInit;
}
if ( false === flexHeight ) {
imgSelectOptions.maxHeight = yInit;
}
if ( false === flexWidth ) {
imgSelectOptions.maxWidth = xInit;
}
return imgSelectOptions;
},
/**
* Return whether the image must be cropped, based on required dimensions.
*
* @param {bool} flexW
* @param {bool} flexH
* @param {int} dstW
* @param {int} dstH
* @param {int} imgW
* @param {int} imgH
* @return {bool}
*/
mustBeCropped: function( flexW, flexH, dstW, dstH, imgW, imgH ){
'use strict';
if ( true === flexW && true === flexH ) {
return false;
}
if ( true === flexW && dstH === imgH ) {
return false;
}
if ( true === flexH && dstW === imgW ) {
return false;
}
if ( dstW === imgW && dstH === imgH ) {
return false;
}
if ( imgW <= dstW ) {
return false;
}
return true;
},
/**
* If cropping was skipped, apply the image data directly to the setting.
*/
onSkippedCrop: function(){
'use strict';
var attachment = this.frame.state().get( 'selection' ).first().toJSON();
this.setImageInRepeaterField( attachment );
},
/**
* Updates the setting and re-renders the control UI.
*
* @param {object} attachment
*/
setImageInRepeaterField: function( attachment ){
'use strict';
var $targetDiv = this.$thisButton.closest( '.repeater-field-image,.repeater-field-cropped_image' );
$targetDiv.find( '.rara-business-image-attachment' ).html( '<img src="' + attachment.url + '">' ).hide().slideDown( 'slow' );
$targetDiv.find( '.hidden-field' ).val( attachment.id );
this.$thisButton.text( this.$thisButton.data( 'alt-label' ) );
$targetDiv.find( '.remove-button' ).show();
//This will activate the save button
$targetDiv.find( 'input, textarea, select' ).trigger( 'change' );
this.frame.close();
},
/**
* Updates the setting and re-renders the control UI.
*
* @param {object} attachment
*/
setFileInRepeaterField: function( attachment ){
'use strict';
var $targetDiv = this.$thisButton.closest( '.repeater-field-upload' );
$targetDiv.find( '.rara-business-file-attachment' ).html( '<span class="file"><span class="dashicons dashicons-media-default"></span> ' + attachment.filename + '</span>' ).hide().slideDown( 'slow' );
$targetDiv.find( '.hidden-field' ).val( attachment.id );
this.$thisButton.text( this.$thisButton.data( 'alt-label' ) );
$targetDiv.find( '.upload-button' ).show();
$targetDiv.find( '.remove-button' ).show();
//This will activate the save button
$targetDiv.find( 'input, textarea, select' ).trigger( 'change' );
this.frame.close();
},
getMimeType: function(){
'use strict';
// We get the field id from which this was called
var currentFieldId = this.$thisButton.siblings( 'input.hidden-field' ).attr( 'data-field' ),
attrs = [ 'mime_type' ]; // A list of attributes to look for
// Make sure we got it
if ( 'string' === typeof currentFieldId && '' !== currentFieldId ) {
// Make fields is defined and only do the hack for cropped_image
if ( 'object' === typeof this.params.fields[ currentFieldId ] && 'upload' === this.params.fields[ currentFieldId ].type ) {
// If the attribute exists in the field
if ( 'undefined' !== typeof this.params.fields[ currentFieldId ].mime_type ) {
// Set the attribute in the main object
return this.params.fields[ currentFieldId ].mime_type;
}
}
}
return 'image';
},
removeImage: function( event ){
'use strict';
var $targetDiv,
$uploadButton;
if ( wp.customize.utils.isKeydownButNotEnterEvent( event ) ) {
return;
}
$targetDiv = this.$thisButton.closest( '.repeater-field-image,.repeater-field-cropped_image,.repeater-field-upload' );
$uploadButton = $targetDiv.find( '.upload-button' );
$targetDiv.find( '.rara-business-image-attachment' ).slideUp( 'fast', function() {
jQuery( this ).show().html( jQuery( this ).data( 'placeholder' ) );
});
$targetDiv.find( '.hidden-field' ).val( '' );
$uploadButton.text( $uploadButton.data( 'label' ) );
this.$thisButton.hide();
$targetDiv.find( 'input, textarea, select' ).trigger( 'change' );
},
removeFile: function( event ){
'use strict';
var $targetDiv,
$uploadButton;
if ( wp.customize.utils.isKeydownButNotEnterEvent( event ) ) {
return;
}
$targetDiv = this.$thisButton.closest( '.repeater-field-upload' );
$uploadButton = $targetDiv.find( '.upload-button' );
$targetDiv.find( '.rara-business-file-attachment' ).slideUp( 'fast', function() {
jQuery( this ).show().html( jQuery( this ).data( 'placeholder' ) );
});
$targetDiv.find( '.hidden-field' ).val( '' );
$uploadButton.text( $uploadButton.data( 'label' ) );
this.$thisButton.hide();
$targetDiv.find( 'input, textarea, select' ).trigger( 'change' );
},
/**
* Get the current value of the setting
*
* @return Object
*/
getValue: function(){
'use strict';
// The setting is saved in JSON
return JSON.parse( decodeURI( this.setting.get() ) );
},
/**
* Set a new value for the setting
*
* @param newValue Object
* @param refresh If we want to refresh the previewer or not
*/
setValue: function( newValue, refresh, filtering ){
'use strict';
// We need to filter the values after the first load to remove data requrired for diplay but that we don't want to save in DB
var filteredValue = newValue,
filter = [];
if ( filtering ) {
jQuery.each( this.params.fields, function( index, value ) {
if ( 'image' === value.type || 'cropped_image' === value.type || 'upload' === value.type ) {
filter.push( index );
}
});
jQuery.each( newValue, function( index, value ) {
jQuery.each( filter, function( ind, field ) {
if ( 'undefined' !== typeof value[field] && 'undefined' !== typeof value[field].id ) {
filteredValue[index][field] = value[field].id;
}
});
});
}
this.setting.set( encodeURI( JSON.stringify( filteredValue ) ) );
if ( refresh ) {
// Trigger the change event on the hidden field so
// previewer refresh the website on Customizer
this.settingField.trigger( 'change' );
}
},
/**
* Add a new row to repeater settings based on the structure.
*
* @param data (Optional) Object of field => value pairs (undefined if you want to get the default values)
*/
addRow: function( data ){
'use strict';
var control = this,
template = control.repeaterTemplate(), // The template for the new row (defined on Rara_Business_Control_Repeater::render_content() ).
settingValue = this.getValue(), // Get the current setting value.
newRowSetting = {}, // Saves the new setting data.
templateData, // Data to pass to the template
newRow,
i;
if ( template ) {
// The control structure is going to define the new fields
// We need to clone control.params.fields. Assigning it
// ould result in a reference assignment.
templateData = jQuery.extend( true, {}, control.params.fields );
// But if we have passed data, we'll use the data values instead
if ( data ) {
for ( i in data ) {
if ( data.hasOwnProperty( i ) && templateData.hasOwnProperty( i ) ) {
templateData[ i ]['default'] = data[ i ];
}
}
}
templateData.index = this.currentIndex;
// Append the template content
template = template( templateData );
// Create a new row object and append the element
newRow = new rarabusinessRepeaterRow(
control.currentIndex,
jQuery( template ).appendTo( control.repeaterFieldsContainer ),
control.params.row_label
);
newRow.container.on( 'row:remove', function( e, rowIndex ) {
control.deleteRow( rowIndex );
});
newRow.container.on( 'row:update', function( e, rowIndex, fieldName, element ) {
control.updateField.call( control, e, rowIndex, fieldName, element );
newRow.updateLabel();
});
// Add the row to rows collection
this.rows[ this.currentIndex ] = newRow;
for ( i in templateData ) {
if ( templateData.hasOwnProperty( i ) ) {
newRowSetting[ i ] = templateData[ i ]['default'];
}
}
settingValue[ this.currentIndex ] = newRowSetting;
this.setValue( settingValue, true );
this.currentIndex++;
return newRow;
}
},
sort: function(){
'use strict';
var control = this,
$rows = this.repeaterFieldsContainer.find( '.repeater-row' ),
newOrder = [],
settings = control.getValue(),
newRows = [],
newSettings = [];
$rows.each( function( i, element ) {
newOrder.push( jQuery( element ).data( 'row' ) );
});
jQuery.each( newOrder, function( newPosition, oldPosition ) {
newRows[ newPosition ] = control.rows[ oldPosition ];
newRows[ newPosition ].setRowIndex( newPosition );
newSettings[ newPosition ] = settings[ oldPosition ];
});
control.rows = newRows;
control.setValue( newSettings );
},
/**
* Delete a row in the repeater setting
*
* @param index Position of the row in the complete Setting Array
*/
deleteRow: function( index ){
'use strict';
var currentSettings = this.getValue(),
row,
i,
prop;
if ( currentSettings[ index ] ) {
// Find the row
row = this.rows[ index ];
if ( row ) {
// The row exists, let's delete it
// Remove the row settings
delete currentSettings[ index ];
// Remove the row from the rows collection
delete this.rows[ index ];
// Update the new setting values
this.setValue( currentSettings, true );
}
}
// Remap the row numbers
i = 1;
for ( prop in this.rows ) {
if ( this.rows.hasOwnProperty( prop ) && this.rows[ prop ] ) {
this.rows[ prop ].updateLabel();
i++;
}
}
},
/**
* Update a single field inside a row.
* Triggered when a field has changed
*
* @param e Event Object
*/
updateField: function( e, rowIndex, fieldId, element ){
'use strict';
var type,
row,
currentSettings;
if ( ! this.rows[ rowIndex ] ) {
return;
}
if ( ! this.params.fields[ fieldId ] ) {
return;
}
type = this.params.fields[ fieldId].type;
row = this.rows[ rowIndex ];
currentSettings = this.getValue();
element = jQuery( element );
if ( 'undefined' === typeof currentSettings[ row.rowIndex ][ fieldId ] ) {
return;
}
if ( 'checkbox' === type ) {
currentSettings[ row.rowIndex ][ fieldId ] = element.is( ':checked' );
} else {
// Update the settings
currentSettings[ row.rowIndex ][ fieldId ] = element.val();
}
this.setValue( currentSettings, true );
},
/**
* Init the color picker on color fields
* Called after AddRow
*
*/
initColorPicker: function(){
'use strict';
var control = this,
colorPicker = control.container.find( '.color-picker-hex' ),
options = {},
fieldId = colorPicker.data( 'field' );
// We check if the color palette parameter is defined.
if ( 'undefined' !== typeof fieldId && 'undefined' !== typeof control.params.fields[ fieldId ] && 'undefined' !== typeof control.params.fields[ fieldId ].palettes && 'object' === typeof control.params.fields[ fieldId ].palettes ) {
options.palettes = control.params.fields[ fieldId ].palettes;
}
// When the color picker value is changed we update the value of the field
options.change = function( event, ui ) {
var currentPicker = jQuery( event.target ),
row = currentPicker.closest( '.repeater-row' ),
rowIndex = row.data( 'row' ),
currentSettings = control.getValue();
currentSettings[ rowIndex ][ currentPicker.data( 'field' ) ] = ui.color.toString();
control.setValue( currentSettings, true );
};
// Init the color picker
if ( 0 !== colorPicker.length ) {
colorPicker.wpColorPicker( options );
}
},
});
jQuery( document ).ready(function($){
'use strict';
$(document).on('click','.repeater-add',function() {
$('.repeater-field').find('input[type="font"]').attr('placeholder','search icons');
});
$(document).on( 'click', 'input[type="font"]', function(){
var $this = $(this);
if( ( ! $this.hasClass('ajax-running') ) && $this.siblings( '.font-awesome-list' ).length < 1 ){
$.ajax({
type: "POST",
url : ajaxurl,
data: {
action : 'rara_business_get_fontawesome_ajax',
rara_business_customize_nonce: rara_business_customize.nonce
},
beforeSend: function(){
$this.addClass('ajax-running');
},
success: function (response) {
var html = '<div class="font-awesome-list">'+response+'</div>';
$this.after(html);
$this.removeClass('ajax-running');
}
});
}
});
$(document).on( 'click', '.font-group li', function(event){
var val = $(this).data( 'font' );
$(this).parent().parent().siblings( 'input[type="font"]' ).val( val );
$(this).parent().parent().siblings( 'input[type="font"]' ).trigger( 'change' );
$(this).parent().parent().fadeOut( 'slow', function(){
$(this).remove();
});
event.preventDefault();
});
$(document).on( 'keyup', 'input[type="font"]', function(){
var value = $(this).val();
var matcher = new RegExp( value, 'gi' );
$(this).next( '.font-awesome-list' ).children('.font-group').children( 'li' ).show().not(function(){
return matcher.test( $(this).find( 'svg' ).attr( 'class' ) );
}).hide();
});
});

View File

@@ -0,0 +1,87 @@
<?php
/**
* Customizer Control: rara-business-select.
*
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Select_Control' ) ) {
/**
* Select control.
*/
class Rara_Business_Select_Control extends WP_Customize_Control {
public $type = 'rara-business-select';
public $multiple = 1;
public $tooltip = '';
public function to_json() {
parent::to_json();
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
} else {
$this->json['default'] = $this->setting->default;
}
$this->json['multiple'] = $this->multiple;
$this->json['value'] = $this->value();
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['tooltip'] = $this->tooltip;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
public function enqueue() {
wp_enqueue_style( 'rara-business-selectize', get_template_directory_uri() . '/inc/custom-controls/select/select.css', null );
wp_enqueue_script( 'rara-business-selectize', get_template_directory_uri() . '/inc/custom-controls/select/selectize.js', array( 'jquery' ) ); //for multi select
wp_enqueue_script( 'rara-business-select', get_template_directory_uri() . '/inc/custom-controls/select/select.js', array( 'jquery', 'rara-business-selectize' ), false, true ); //for multi select
}
protected function content_template() {
?>
<# if ( ! data.choices ) return; #>
<# if ( data.tooltip ) { #>
<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
<# } #>
<label>
<# if ( data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
<select {{{ data.inputAttrs }}} {{{ data.link }}} data-multiple="{{ data.multiple }}"<# if ( 1 < data.multiple ) { #> multiple<# } #>>
<# if ( 1 < data.multiple && data.value ) { #>
<# for ( key in data.value ) { #>
<option value="{{ data.value[ key ] }}" selected>{{ data.choices[ data.value[ key ] ] }}</option>
<# } #>
<# for ( key in data.choices ) { #>
<# if ( data.value[ key ] in data.value ) { #>
<# } else { #>
<option value="{{ key }}">{{ data.choices[ key ] }}</option>
<# } #>
<# } #>
<# } else { #>
<# for ( key in data.choices ) { #>
<option value="{{ key }}"<# if ( key === data.value ) { #>selected<# } #>>{{ data.choices[ key ] }}</option>
<# } #>
<# } #>
</select>
</label>
<?php
}
}
}

View File

@@ -0,0 +1,300 @@
/* Select Control */
.selectize-control {
position: relative;
}
.selectize-control.single .selectize-input,
.selectize-control.single .selectize-input input {
cursor: pointer;
}
.selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active input {
cursor: text;
}
.selectize-control.single .selectize-input:after {
content: "\f347";
display: block;
position: absolute;
top: 0;
right: 0;
margin-top: 0;
width: 12px;
height: 36px;
font-family: dashicons;
border-left: 1px solid rgba(0, 0, 0, 0.06);
line-height: 36px;
padding: 0 3px;
}
.selectize-control.single .selectize-input.dropdown-active:after {
content: "\f343";
border-left: 1px solid rgba(0, 0, 0, 0.1);
}
.selectize-control.single .selectize-input.disabled {
opacity: 0.5;
background-color: #fafafa;
}
.selectize-control.single.rtl .selectize-input:after {
left: 15px;
right: auto;
}
.selectize-control.rtl .selectize-input > input {
margin: 0 4px 0 -2px !important;
}
.selectize-control .plugin-drag_drop.multi > .selectize-input > div.ui-sortable-placeholder {
visibility: visible !important;
background: #f2f2f2 !important;
background: rgba(0, 0, 0, 0.06) !important;
border: 0 none !important;
-webkit-box-shadow: inset 0 0 12px 4px #ffffff;
box-shadow: inset 0 0 12px 4px #ffffff;
}
.selectize-control .plugin-drag_drop .ui-sortable-placeholder::after {
content: '!';
visibility: hidden;
}
.selectize-control .plugin-drag_drop .ui-sortable-helper {
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.selectize-control .plugin-remove_button [data-value] {
position: relative;
padding-right: 24px !important;
}
.selectize-control .plugin-remove_button [data-value] .remove {
z-index: 1;
/* fixes ie bug (see #392) */
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 17px;
text-align: center;
font-weight: bold;
font-size: 12px;
color: inherit;
text-decoration: none;
vertical-align: middle;
display: inline-block;
padding: 2px 0 0 0;
border-left: 1px solid #d0d0d0;
-webkit-border-radius: 0 2px 2px 0;
-moz-border-radius: 0 2px 2px 0;
border-radius: 0 2px 2px 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.selectize-control .plugin-remove_button .remove:hover {
background: rgba(0, 0, 0, 0.05);
}
.selectize-control .plugin-remove_button.active .remove {
border-left-color: #cacaca;
}
.selectize-control .plugin .disabled [data-value] .remove:hover {
background: none;
}
.selectize-control .plugin .disabled [data-value] .remove {
border-left-color: #ffffff;
}
.selectize-control.multi .selectize-input {
min-height: 36px;
}
.selectize-control.multi .selectize-input.has-items {
padding: 6px 8px 3px;
}
.selectize-control.multi .selectize-input > div {
cursor: pointer;
margin: 0 3px 3px 0;
padding: 2px 6px;
background: #f2f2f2;
color: #303030;
border: 0 solid #d0d0d0;
}
.selectize-control.multi .selectize-input > div.active {
background: #e8e8e8;
color: #303030;
border: 0 solid #cacaca;
}
.selectize-control.multi .selectize-input.disabled > div, .selectize-control.multi .selectize-input.disabled > div.active {
color: #7d7d7d;
background: #ffffff;
border: 0 solid #ffffff;
}
.selectize-dropdown {
position: relative;
top: -4px !important;
z-index: 10;
border: 1px solid #d0d0d0;
background: #ffffff;
margin: -1px 0 0 0;
border-top: 0 none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
-webkit-border-radius: 0 0 3px 3px;
-moz-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
z-index: 999;
}
.selectize-dropdown-header {
position: relative;
padding: 5px 8px;
border-bottom: 1px solid #d0d0d0;
background: #f8f8f8;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
.selectize-dropdown-header-close {
position: absolute;
right: 8px;
top: 50%;
color: #303030;
opacity: 0.4;
margin-top: -12px;
line-height: 20px;
font-size: 20px !important;
}
.selectize-dropdown-header-close:hover {
color: #000000;
}
.selectize-dropdown.plugin-optgroup_columns .optgroup {
border-right: 1px solid #f2f2f2;
border-top: 0 none;
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.selectize-dropdown.plugin-optgroup_columns .optgroup:last-child {
border-right: 0 none;
}
.selectize-dropdown.plugin-optgroup_columns .optgroup:before {
display: none;
}
.selectize-dropdown.plugin-optgroup_columns .optgroup-header {
border-top: 0 none;
}
.selectize-dropdown, .selectize-input, .selectize-input input {
color: #303030;
font-family: inherit;
font-size: 13px;
line-height: 18px;
-webkit-font-smoothing: inherit;
}
.selectize-input, .selectize-control.single .selectize-input.input-active {
background: #ffffff;
cursor: text;
display: inline-block;
}
.selectize-input {
border: 1px solid rgba(0, 0, 0, 0.1);
padding: 8px 8px;
display: inline-block;
width: 100%;
overflow: hidden;
position: relative;
z-index: 1;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.selectize-input.full {
background-color: #ffffff;
}
.selectize-input.disabled, .selectize-input.disabled * {
cursor: default !important;
}
.selectize-input.focus {
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.selectize-input.dropdown-active {
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
.selectize-input > * {
vertical-align: baseline;
display: -moz-inline-stack;
display: inline-block;
zoom: 1;
*display: inline;
}
.selectize-input > input {
display: inline-block !important;
padding: 0 !important;
min-height: 0 !important;
max-height: none !important;
max-width: 100% !important;
margin: 0 2px 0 0 !important;
text-indent: 0 !important;
border: 0 none !important;
background: none !important;
line-height: inherit !important;
-webkit-user-select: auto !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
.selectize-input > input::-ms-clear {
display: none;
}
.selectize-input > input:focus {
outline: none !important;
}
.selectize-input::after {
content: ' ';
display: block;
clear: left;
}
.selectize-input.dropdown-active::before {
content: ' ';
display: block;
position: absolute;
background: #f0f0f0;
height: 1px;
bottom: 0;
left: 0;
right: 0;
}
.selectize-dropdown [data-selectable] {
cursor: pointer;
overflow: hidden;
}
.selectize-dropdown [data-selectable] .highlight {
background: rgba(125, 168, 208, 0.2);
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
}
.selectize-dropdown [data-selectable],
.selectize-dropdown .optgroup-header {
padding: 5px 8px;
}
.selectize-dropdown .optgroup:first-child .optgroup-header {
border-top: 0 none;
}
.selectize-dropdown .optgroup-header {
color: #303030;
background: #ffffff;
cursor: default;
}
.selectize-dropdown .active {
background-color: #f5fafd;
color: #495c68;
}
.selectize-dropdown .active.create {
color: #495c68;
}
.selectize-dropdown .create {
color: rgba(48, 48, 48, 0.5);
}
.selectize-dropdown-content {
overflow-y: auto;
overflow-x: hidden;
max-height: 200px;
}
/* Select Control Ends */

View File

@@ -0,0 +1,41 @@
/*jshint -W065 */
wp.customize.controlConstructor['rara-business-select'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this,
element = this.container.find( 'select' ),
multiple = parseInt( element.data( 'multiple' ) ),
selectValue;
// If this is a multi-select control,
// then we'll need to initialize selectize using the appropriate arguments.
// If this is a single-select, then we can initialize selectize without any arguments.
if ( multiple > 1 ) {
jQuery( element ).selectize({
maxItems: multiple,
plugins: ['remove_button', 'drag_drop']
});
} else {
jQuery( element ).selectize();
}
// Change value
this.container.on( 'change', 'select', function() {
selectValue = jQuery( this ).val();
// If this is a multi-select, then we need to convert the value to an object.
if ( multiple > 1 ) {
selectValue = _.extend( {}, jQuery( this ).val() );
}
control.setting.set( selectValue );
});
}
});

View File

@@ -0,0 +1,79 @@
<?php
/**
* Customizer Control: slider.
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Slider_Control' ) ) {
/**
* Slider control (range).
*/
class Rara_Business_Slider_Control extends WP_Customize_Control {
public $type = 'slider';
public $tooltip = '';
public function to_json() {
parent::to_json();
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
} else {
$this->json['default'] = $this->setting->default;
}
$this->json['value'] = $this->value();
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['tooltip'] = $this->tooltip;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
$this->json['choices']['min'] = ( isset( $this->choices['min'] ) ) ? $this->choices['min'] : '0';
$this->json['choices']['max'] = ( isset( $this->choices['max'] ) ) ? $this->choices['max'] : '100';
$this->json['choices']['step'] = ( isset( $this->choices['step'] ) ) ? $this->choices['step'] : '1';
}
public function enqueue() {
wp_enqueue_style( 'rara-business-slider', get_template_directory_uri() . '/inc/custom-controls/slider/slider.css', null );
wp_enqueue_script( 'rara-business-slider', get_template_directory_uri() . '/inc/custom-controls/slider/slider.js', array( 'jquery' ), false, true ); //for slider
}
protected function content_template() {
?>
<# if ( data.tooltip ) { #>
<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
<# } #>
<label>
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
<div class="wrapper">
<input {{{ data.inputAttrs }}} type="range" min="{{ data.choices['min'] }}" max="{{ data.choices['max'] }}" step="{{ data.choices['step'] }}" value="{{ data.value }}" {{{ data.link }}} data-reset_value="{{ data.default }}" />
<div class="range_value">
<span class="value">{{ data.value }}</span>
<# if ( data.choices['suffix'] ) { #>
{{ data.choices['suffix'] }}
<# } #>
</div>
<div class="slider-reset">
<span class="dashicons dashicons-image-rotate"></span>
</div>
</div>
</label>
<?php
}
}
}

View File

@@ -0,0 +1,94 @@
.customize-control-slider input[type=range] {
-webkit-appearance: none;
-webkit-transition: background .3s;
-moz-transition: background .3s;
transition: background .3s;
background-color: rgba(0, 0, 0, 0.1);
height: 5px;
width: calc(100% - 70px);
padding: 0;
}
.customize-control-slider input[type=range]:focus {
box-shadow: none;
outline: none;
}
.customize-control-slider input[type=range]:hover {
background-color: rgba(0, 0, 0, 0.25);
}
.customize-control-slider input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 15px;
height: 15px;
border-radius: 50%;
-webkit-border-radius: 50%;
background-color: #3498D9;
}
.customize-control-slider input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 15px;
height: 15px;
border: none;
border-radius: 50%;
background-color: #3498D9;
}
.customize-control-slider input[type=range]::-moz-range-thumb {
width: 15px;
height: 15px;
border: none;
border-radius: 50%;
background-color: #3498D9;
}
.customize-control-slider input[type=range]::-ms-thumb {
width: 15px;
height: 15px;
border-radius: 50%;
border: 0;
background-color: #3498D9;
}
.customize-control-slider input[type=range]::-moz-range-track {
border: inherit;
background: transparent;
}
.customize-control-slider input[type=range]::-ms-track {
border: inherit;
color: transparent;
background: transparent;
}
.customize-control-slider input[type=range]::-ms-fill-lower, .customize-control-slider input[type=range]::-ms-fill-upper {
background: transparent;
}
.customize-control-slider input[type=range]::-ms-tooltip {
display: none;
}
.customize-control-slider .range_value {
display: inline-block;
font-size: 14px;
padding: 0 5px;
font-weight: 400;
position: relative;
top: 2px;
}
.customize-control-slider .range_value {
display: inline-block;
font-size: 14px;
padding: 0 5px;
font-weight: 400;
position: relative;
top: 2px;
}
.customize-control-slider .slider-reset {
color: rgba(0, 0, 0, 0.2);
float: right;
-webkit-transition: color .5s ease-in;
-moz-transition: color .5s ease-in;
-ms-transition: color .5s ease-in;
-o-transition: color .5s ease-in;
transition: color .5s ease-in;
}
.customize-control-slider .slider-reset span {
font-size: 16px;
line-height: 22px;
}
.customize-control-slider .slider-reset:hover {
color: red;
}

View File

@@ -0,0 +1,39 @@
wp.customize.controlConstructor['slider'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this,
value,
thisInput,
inputDefault,
changeAction;
// Update the text value
jQuery(document).on('input change', 'input[type=range]', function() {
jQuery( this ).closest( 'label' ).find( '.range_value .value' ).html(jQuery(this).val());
});
// Handle the reset button
jQuery( '.slider-reset' ).on( 'click', function() {
thisInput = jQuery( this ).closest( 'label' ).find( 'input' );
inputDefault = thisInput.data( 'reset_value' );
thisInput.val( inputDefault );
thisInput.change();
jQuery( this ).closest( 'label' ).find( '.range_value .value' ).text( inputDefault );
});
if ( 'postMessage' === control.setting.transport ) {
changeAction = 'mousemove change';
} else {
changeAction = 'change';
}
// Save changes.
this.container.on( changeAction, 'input', function() {
control.setting.set( jQuery( this ).val() );
});
}
});

View File

@@ -0,0 +1,65 @@
<?php
/**
* Customizer Control: toggle.
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Rara_Business_Toggle_Control' ) ) {
/**
* Toggle control (modified checkbox).
*/
class Rara_Business_Toggle_Control extends WP_Customize_Control {
public $type = 'toggle';
public $tooltip = '';
public function to_json() {
parent::to_json();
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
} else {
$this->json['default'] = $this->setting->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['tooltip'] = $this->tooltip;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
public function enqueue() {
wp_enqueue_style( 'rara-business-toggle', get_template_directory_uri() . '/inc/custom-controls/toggle/toggle.css', null );
wp_enqueue_script( 'rara-business-toggle', get_template_directory_uri() . '/inc/custom-controls/toggle/toggle.js', array( 'jquery' ), false, true ); //for toggle
}
protected function content_template() {
?>
<# if ( data.tooltip ) { #>
<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
<# } #>
<label for="toggle_{{ data.id }}">
<span class="customize-control-title">
{{{ data.label }}}
</span>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
<input {{{ data.inputAttrs }}} name="toggle_{{ data.id }}" id="toggle_{{ data.id }}" type="checkbox" value="{{ data.value }}" {{{ data.link }}}<# if ( '1' == data.value ) { #> checked<# } #> hidden />
<span class="switch"></span>
</label>
<?php
}
}
}

View File

@@ -0,0 +1,64 @@
.customize-control-toggle label {
display: flex;
flex-wrap: wrap;
}
.customize-control-toggle label .customize-control-title {
width: calc(100% - 55px);
}
.customize-control-toggle label .description {
order: 99;
}
.customize-control-toggle input[type="checkbox"] {
display: none;
}
.customize-control-toggle .switch {
border: 1px solid rgba(0, 0, 0, 0.1);
display: inline-block;
width: 35px;
height: 12px;
border-radius: 8px;
background: #ccc;
vertical-align: middle;
position: relative;
cursor: pointer;
user-select: none;
transition: background 350ms ease;
}
.customize-control-toggle .switch:before, .customize-control-toggle .switch:after {
content: "";
display: block;
width: 20px;
height: 20px;
border-radius: 50%;
position: absolute;
top: 50%;
left: -3px;
transition: all 350ms cubic-bezier(0, 0.95, 0.38, 0.98), background 150ms ease;
}
.customize-control-toggle .switch:before {
background: rgba(0, 0, 0, 0.2);
transform: translate3d(0, -50%, 0) scale(0);
}
.customize-control-toggle .switch:after {
background: #999;
border: 1px solid rgba(0, 0, 0, 0.1);
transform: translate3d(0, -50%, 0);
}
.customize-control-toggle .switch:active:before {
transform: translate3d(0, -50%, 0) scale(3);
}
.customize-control-toggle input:checked + .switch {
background: rgba(52, 152, 222, 0.3);
}
.customize-control-toggle input:checked + .switch:before {
background: rgba(52, 152, 222, 0.075);
transform: translate3d(100%, -50%, 0) scale(1);
}
.customize-control-toggle input:checked + .switch:after {
background: #3498DE;
transform: translate3d(100%, -50%, 0);
}
.customize-control-toggle input:checked + .switch:active:before {
background: rgba(52, 152, 222, 0.075);
transform: translate3d(100%, -50%, 0) scale(3);
}

View File

@@ -0,0 +1,18 @@
wp.customize.controlConstructor['toggle'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this,
checkboxValue = control.setting._value;
// Save the value
this.container.on( 'change', 'input', function() {
checkboxValue = ( jQuery( this ).is( ':checked' ) ) ? true : false;
control.setting.set( checkboxValue );
});
}
});

View File

@@ -0,0 +1,562 @@
<?php
/**
* Rara Business Custom functions
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function rara_business_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Rara Business, use a find and replace
* to change 'rara-business' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'rara-business', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'rara-business' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-list',
'gallery',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'rara_business_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add excerpt support for page.
add_post_type_support( 'page', 'excerpt' );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'header-text' => array( 'site-title', 'site-description' ),
) );
add_theme_support( 'custom-header', apply_filters( 'rara_business_custom_header_args', array(
'default-image' => get_template_directory_uri().'/images/banner-image.jpg',
'width' => 1920,
'height' => 780,
'header-text' => false,
'video' => true,
) ) );
register_default_headers( array(
'default-image' => array(
'url' => '%s/images/banner-image.jpg',
'thumbnail_url' => '%s/images/banner-image.jpg',
'description' => __( 'Default Header Image', 'rara-business' ),
),
) );
/** Images sizes */
add_image_size( 'rara-business-featured', 770, 499, true );
add_image_size( 'rara-business-team', 370, 280, true );
add_image_size( 'rara-business-blog', 370, 240, true );
add_image_size( 'rara-business-portfolio', 370, 370, true );
add_image_size( 'rara-business-schema', 600, 60 );
/** Starter Content */
$starter_content = array(
// Specify the core-defined pages to create and add custom thumbnails to some of them.
'posts' => array(
'home',
'blog',
'portfolio' => array(
'post_type' => 'page',
'post_title' => 'Portfolio',
'template' => 'templates/portfolio.php',
)
),
// Default to a static front page and assign the front and posts pages.
'options' => array(
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
),
// Set up nav menus for each of the two areas registered in the theme.
'nav_menus' => array(
// Assign a menu to the "top" location.
'primary' => array(
'name' => __( 'Primary', 'rara-business' ),
'items' => array(
'page_home',
'page_blog',
'page_portfolio' => array(
'type' => 'post_type',
'object' => 'page',
'object_id' => '{{portfolio}}',
)
)
)
),
);
$starter_content = apply_filters( 'rara_business_starter_content', $starter_content );
add_theme_support( 'starter-content', $starter_content );
// Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' );
remove_theme_support( 'widgets-block-editor' );
}
endif;
add_action( 'after_setup_theme', 'rara_business_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function rara_business_content_width() {
$GLOBALS['content_width'] = apply_filters( 'rara_business_content_width', 770 );
}
add_action( 'after_setup_theme', 'rara_business_content_width', 0 );
/**
* Enqueue scripts and styles.
*/
function rara_business_scripts() {
// Use minified libraries if SCRIPT_DEBUG is turned off
$build = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '/build' : '';
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
$rtc_activated = rara_business_is_rara_theme_companion_activated();
wp_enqueue_style( 'animate', get_template_directory_uri(). '/css' . $build . '/animate' . $suffix . '.css', array(), '3.5.2' );
if( get_theme_mod( 'ed_localgoogle_fonts',false ) && ! is_customize_preview() && ! is_admin() ){
if ( get_theme_mod( 'ed_preload_local_fonts',false ) ) {
rara_business_load_preload_local_fonts( rara_business_get_webfont_url( rara_business_fonts_url() ) );
}
wp_enqueue_style( 'rara-business-google-fonts', rara_business_get_webfont_url( rara_business_fonts_url() ) );
}else{
wp_enqueue_style( 'rara-business-google-fonts', rara_business_fonts_url(), array(), null );
}
if( rara_business_is_woocommerce_activated() ){
wp_enqueue_style( 'rara-business-woocommerce', get_template_directory_uri(). '/css' . $build . '/woocommerce-style' . $suffix . '.css' );
}
if( $rtc_activated && is_active_widget( false, false, 'rrtc_description_widget' ) ){
wp_enqueue_style( 'perfect-scrollbar', get_template_directory_uri(). '/css' . $build . '/perfect-scrollbar' . $suffix . '.css', array(), '1.3.0' );
wp_enqueue_script( 'perfect-scrollbar', get_template_directory_uri() . '/js' . $build . '/perfect-scrollbar' . $suffix . '.js', array( 'jquery' ), '1.3.0', true );
}
wp_enqueue_style( 'rara-business-style', get_stylesheet_uri(), array(), RARA_BUSINESS_THEME_VERSION );
if( $rtc_activated && ( is_front_page() || is_page_template( 'templates/portfolio.php' ) ) ){
wp_enqueue_script( 'masonry' );
wp_enqueue_script( 'isotope-pkgd', get_template_directory_uri() . '/js' . $build . '/isotope.pkgd' . $suffix . '.js', array( 'jquery' ), '3.0.5', true );
}
wp_enqueue_script( 'all', get_template_directory_uri() . '/js' . $build . '/all' . $suffix . '.js', array( 'jquery' ), '6.1.1', true );
wp_enqueue_script( 'v4-shims', get_template_directory_uri() . '/js' . $build . '/v4-shims' . $suffix . '.js', array( 'jquery' ), '6.1.1', true );
wp_enqueue_script( 'rara-business-modal-accessibility', get_template_directory_uri() . '/js' . $build . '/modal-accessibility' . $suffix . '.js', array( 'jquery' ), RARA_BUSINESS_THEME_VERSION, true );
if( get_theme_mod( 'ed_animation',true ) ){
wp_enqueue_script( 'wow', get_template_directory_uri() . '/js' . $build . '/wow' . $suffix . '.js', array( 'jquery' ), RARA_BUSINESS_THEME_VERSION, true );
}
// Register custom js
wp_register_script( 'rara-business-custom', get_template_directory_uri() . '/js' . $build . '/custom' . $suffix . '.js', array( 'jquery' ), RARA_BUSINESS_THEME_VERSION, true );
$localize_array = array(
// Rtl
'rtl' => is_rtl(),
'animation' => esc_attr( get_theme_mod( 'ed_animation', true ) ),
);
wp_localize_script( 'rara-business-custom', 'rb_localize_data', $localize_array );
// Enqueued custom script with localized data.
wp_enqueue_script( 'rara-business-custom' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'rara_business_scripts' );
/**
* Enqueue admin scripts.
*/
function rara_business_admin_scripts( $hook_suffix ) {
// Register admin js script
wp_register_script( 'rara-business-admin-js', get_template_directory_uri().'/inc/js/admin.js', array( 'jquery' ), RARA_BUSINESS_THEME_VERSION, true );
// localize script to remove metabox in front page
$show_front = get_option( 'show_on_front' ); //What to show on the front page
$front_page_id = get_option( 'page_on_front' ); //The ID of the static front page.
$frontpage_sections = rara_business_get_home_sections();
$admin_data = array();
if ( $hook_suffix == 'post.php' || $hook_suffix == 'post-new.php' ) {
if( isset( $_GET['post'] ) && ! empty( $_GET['post'] ) ) {
$post_id = $_GET['post'];
} else {
$post_id = -9999;
}
// Get page template
$page_template = get_page_template_slug( $post_id );
if( ( 'page' == $show_front && $front_page_id > 0 ) && $post_id == $front_page_id && ! empty( $frontpage_sections ) ){
$admin_data['hide_metabox'] = 1;
} elseif ( '' != $page_template ) {
$admin_data['hide_metabox'] = 1;
} else {
$admin_data['hide_metabox'] = '';
}
}else {
$admin_data['hide_metabox'] = '';
}
wp_localize_script( 'rara-business-admin-js', 'rb_show_metabox', $admin_data );
// Enqueued script with localized data.
wp_enqueue_script( 'rara-business-admin-js' );
wp_enqueue_style( 'rara-business-admin-style', get_template_directory_uri() . '/inc/css/admin.css', '', RARA_BUSINESS_THEME_VERSION );
}
add_action( 'admin_enqueue_scripts', 'rara_business_admin_scripts' );
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function rara_business_body_classes( $classes ) {
$default_options = rara_business_default_theme_options(); // Get default theme options
$banner_control = get_theme_mod( 'ed_banner_section', $default_options['ed_banner_section'] );
$custom_header_image = get_header_image_tag(); // get custom header image tag
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
if( is_front_page() && ! is_home() && ( has_header_video() || ! empty( $custom_header_image ) ) && 'no_banner' != $banner_control ){
$classes[] = 'homepage hasbanner';
}
// Add sibebar layout classes.
$classes[] = rara_business_sidebar_layout();
return $classes;
}
add_filter( 'body_class', 'rara_business_body_classes' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function rara_business_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'rara_business_pingback_header' );
if( ! function_exists( 'rara_business_change_comment_form_default_fields' ) ) :
/**
* Change Comment form default fields i.e. author, email & url.
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function rara_business_change_comment_form_default_fields( $fields ){
// get the current commenter if available
$commenter = wp_get_current_commenter();
// core functionality
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$required = ( $req ? " required" : '' );
$author = ( $req ? __( 'Name*', 'rara-business' ) : __( 'Name', 'rara-business' ) );
$email = ( $req ? __( 'Email*', 'rara-business' ) : __( 'Email', 'rara-business' ) );
// Change just the author field
$fields['author'] = '<p class="comment-form-author"><label class="screen-reader-text" for="author">' . esc_html__( 'Name', 'rara-business' ) . '<span class="required">*</span></label><input id="author" name="author" placeholder="' . esc_attr( $author ) . '" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $required . ' /></p>';
$fields['email'] = '<p class="comment-form-email"><label class="screen-reader-text" for="email">' . esc_html__( 'Email', 'rara-business' ) . '<span class="required">*</span></label><input id="email" name="email" placeholder="' . esc_attr( $email ) . '" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . $required. ' /></p>';
$fields['url'] = '<p class="comment-form-url"><label class="screen-reader-text" for="url">' . esc_html__( 'Website', 'rara-business' ) . '</label><input id="url" name="url" placeholder="' . esc_attr__( 'Website', 'rara-business' ) . '" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>';
return $fields;
}
endif;
add_filter( 'comment_form_default_fields', 'rara_business_change_comment_form_default_fields' );
if( ! function_exists( 'rara_business_change_comment_form_defaults' ) ) :
/**
* Change Comment Form defaults
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function rara_business_change_comment_form_defaults( $defaults ){
$defaults['comment_field'] = '<p class="comment-form-comment"><label class="screen-reader-text" for="comment">' . esc_html__( 'Comment', 'rara-business' ) . '</label><textarea id="comment" name="comment" placeholder="' . esc_attr__( 'Comment', 'rara-business' ) . '" cols="45" rows="8" aria-required="true" required></textarea></p>';
return $defaults;
}
endif;
add_filter( 'comment_form_defaults', 'rara_business_change_comment_form_defaults' );
if ( ! function_exists( 'rara_business_excerpt_more' ) ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... *
*/
function rara_business_excerpt_more( $more ) {
return is_admin() ? $more : ' &hellip; ';
}
endif;
add_filter( 'excerpt_more', 'rara_business_excerpt_more' );
if ( ! function_exists( 'rara_business_excerpt_length' ) ) :
/**
* Changes the default 55 character in excerpt
*/
function rara_business_excerpt_length( $length ) {
$excerpt_length = get_theme_mod( 'excerpt_length', 55 );
return is_admin() ? $length : absint( $excerpt_length );
}
endif;
add_filter( 'excerpt_length', 'rara_business_excerpt_length', 999 );
if ( !function_exists( 'rara_business_video_controls' ) ) :
/**
* Customize video play/pause button in the custom header.
*
* @param array $settings Video settings.
*/
function rara_business_video_controls( $settings ) {
$settings['l10n']['play'] = '<span class="screen-reader-text">' . __( 'Play background video', 'rara-business' ) . '</span>' . rara_business_get_svg( array( 'icon' => 'play' ) );
$settings['l10n']['pause'] = '<span class="screen-reader-text">' . __( 'Pause background video', 'rara-business' ) . '</span>' . rara_business_get_svg( array( 'icon' => 'pause' ) );
return $settings;
}
endif;
add_filter( 'header_video_settings', 'rara_business_video_controls' );
if( ! function_exists( 'rara_business_include_svg_icons' ) ) :
/**
* Add SVG definitions to the footer.
*/
function rara_business_include_svg_icons() {
// Define SVG sprite file.
$svg_icons = get_parent_theme_file_path( '/images/svg-icons.svg' );
// If it exists, include it.
if ( file_exists( $svg_icons ) ) {
require_once( $svg_icons );
}
}
endif;
add_action( 'wp_footer', 'rara_business_include_svg_icons', 9999 );
if( ! function_exists( 'rara_business_get_the_archive_title' ) ) :
/**
* Filter Archive Title
*/
function rara_business_get_the_archive_title( $title ){
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$hide_prefix = get_theme_mod( 'ed_prefix_archive', $default_options['ed_prefix_archive'] );
if( $hide_prefix ){
if( is_category() ){
$title = single_cat_title( '', false );
}elseif ( is_tag() ){
$title = single_tag_title( '', false );
}elseif( is_author() ){
$title = '<span class="vcard">' . get_the_author() . '</span>';
}elseif ( is_year() ) {
$title = get_the_date( __( 'Y', 'rara-business' ) );
}elseif ( is_month() ) {
$title = get_the_date( __( 'F Y', 'rara-business' ) );
}elseif ( is_day() ) {
$title = get_the_date( __( 'F j, Y', 'rara-business' ) );
}elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
}elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
$title = single_term_title( '', false );
}
}
return $title;
}
endif;
add_filter( 'get_the_archive_title', 'rara_business_get_the_archive_title' );
if( ! function_exists( 'rara_business_get_comment_author_link' ) ) :
/**
* Filter to modify comment author link
* @link https://developer.wordpress.org/reference/functions/get_comment_author_link/
*/
function rara_business_get_comment_author_link( $return, $author, $comment_ID ){
$comment = get_comment( $comment_ID );
$url = get_comment_author_url( $comment );
$author = get_comment_author( $comment );
if ( empty( $url ) || 'http://' == $url )
$return = '<span itemprop="name">'. esc_html( $author ) .'</span>';
else
$return = '<span itemprop="name"><a href="'. esc_url( $url ) .'" rel="external nofollow" class="url" itemprop="url">'. esc_html( $author ) .'</a></span>';
return $return;
}
endif;
add_filter( 'get_comment_author_link', 'rara_business_get_comment_author_link', 10, 3 );
if( ! function_exists( 'rara_business_admin_notice' ) ) :
/**
* Addmin notice for getting started page
*/
function rara_business_admin_notice(){
global $pagenow;
$theme_args = wp_get_theme();
$meta = get_option( 'rara_business_admin_notice' );
$name = $theme_args->__get( 'Name' );
$current_screen = get_current_screen();
$dismissnonce = wp_create_nonce( 'rara_business_admin_notice' );
if( 'themes.php' == $pagenow && !$meta ){
if( $current_screen->id !== 'dashboard' && $current_screen->id !== 'themes' ){
return;
}
if( is_network_admin() ){
return;
}
if( ! current_user_can( 'manage_options' ) ){
return;
} ?>
<div class="welcome-message notice notice-info">
<div class="notice-wrapper">
<div class="notice-text">
<h3><?php esc_html_e( 'Congratulations!', 'rara-business' ); ?></h3>
<p><?php printf( __( '%1$s is now installed and ready to use. Click below to see theme documentation, plugins to install and other details to get started.', 'rara-business' ), esc_html( $name ) ) ; ?></p>
<p><a href="<?php echo esc_url( admin_url( 'themes.php?page=rara-business-dashboard' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Go to the dashboard.', 'rara-business' ); ?></a></p>
<p class="dismiss-link"><strong><a href="?rara_business_admin_notice=1&_wpnonce=<?php echo esc_attr( $dismissnonce ); ?>"><?php esc_html_e( 'Dismiss', 'rara-business' ); ?></a></strong></p>
</div>
</div>
</div>
<?php }
}
endif;
add_action( 'admin_notices', 'rara_business_admin_notice' );
if( ! function_exists( 'rara_business_update_admin_notice' ) ) :
/**
* Updating admin notice on dismiss
*/
function rara_business_update_admin_notice(){
if (!current_user_can('manage_options')) {
return;
}
// Bail if the nonce doesn't check out
if ( isset( $_GET['rara_business_admin_notice'] ) && $_GET['rara_business_admin_notice'] = '1' && wp_verify_nonce( $_GET['_wpnonce'], 'rara_business_admin_notice' ) ) {
update_option( 'rara_business_admin_notice', true );
}
}
endif;
add_action( 'admin_init', 'rara_business_update_admin_notice' );
if( ! function_exists( 'rara_business_get_page_id_by_template' ) ) :
/**
* Returns Page ID by Page Template
*/
function rara_business_get_page_id_by_template( $template_name ){
$args = array(
'meta_key' => '_wp_page_template',
'meta_value' => $template_name
);
return get_pages( $args );
}
endif;
if ( ! function_exists( 'rara_business_get_fontawesome_ajax' ) ) :
/**
* Return an array of all icons.
*/
function rara_business_get_fontawesome_ajax() {
// Bail if the nonce doesn't check out
if ( ! isset( $_POST['rara_business_customize_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['rara_business_customize_nonce'] ), 'rara_business_customize_nonce' ) ) {
wp_die();
}
// Do another nonce check
check_ajax_referer( 'rara_business_customize_nonce', 'rara_business_customize_nonce' );
// Bail if user can't edit theme options
if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die();
}
// Get all of our fonts
$fonts = rara_business_get_fontawesome_list();
ob_start();
if( $fonts ){ ?>
<ul class="font-group">
<?php
foreach( $fonts as $font ){
echo '<li data-font="' . esc_attr( $font ) . '"><i class="' . esc_attr( $font ) . '"></i></li>';
}
?>
</ul>
<?php
}
echo ob_get_clean();
// Exit
wp_die();
}
endif;
add_action( 'wp_ajax_rara_business_get_fontawesome_ajax', 'rara_business_get_fontawesome_ajax' );

View File

@@ -0,0 +1,292 @@
<?php
/**
* Rara_Business Customizer Notification Section Class.
*
* @package Rara_Business
*/
/**
* Rara_Business_Customizer_Notice_Section class
*/
class Rara_Business_Customizer_Notice_Section extends WP_Customize_Section {
/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'customizer-plugin-notice-section';
/**
* Custom button text to output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $recommended_actions = '';
/**
* Recommended Plugins.
*
* @var string
*/
public $recommended_plugins = '';
/**
* Total number of required actions.
*
* @var string
*/
public $total_actions = '';
/**
* Plugin text.
*
* @var string
*/
public $plugin_text = '';
/**
* Dismiss button.
*
* @var string
*/
public $dismiss_button = '';
/**
* Check if plugin is installed/activated
*
* @param plugin-slug $slug the plugin slug.
*
* @return array
*/
public function check_active( $slug ) {
if ( file_exists( ABSPATH . 'wp-content/plugins/' . $slug . '/' . $slug . '.php' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$needs = is_plugin_active( $slug . '/' . $slug . '.php' ) ? 'deactivate' : 'activate';
return array(
'status' => is_plugin_active( $slug . '/' . $slug . '.php' ),
'needs' => $needs,
);
}
return array(
'status' => false,
'needs' => 'install',
);
}
/**
* Create the install/activate button link for plugins
*
* @param plugin-state $state The plugin state (not installed/inactive/active).
* @param plugin-slug $slug The plugin slug.
*
* @return mixed
*/
public function create_action_link( $state, $slug ) {
switch ( $state ) {
case 'install':
return wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $slug,
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $slug
);
break;
case 'deactivate':
return add_query_arg(
array(
'action' => 'deactivate',
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ),
), network_admin_url( 'plugins.php' )
);
break;
case 'activate':
return add_query_arg(
array(
'action' => 'activate',
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ),
), network_admin_url( 'plugins.php' )
);
break;
}// End switch().
}
/**
* Call plugin API to get plugins info
*
* @param plugin-slug $slug The plugin slug.
*
* @return mixed
*/
public function call_plugin_api( $slug ) {
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
$call_api = get_transient( 'cust_notice_plugin_info_' . $slug );
if ( false === $call_api ) {
$call_api = plugins_api(
'plugin_information', array(
'slug' => $slug,
'fields' => array(
'downloaded' => false,
'rating' => false,
'description' => false,
'short_description' => true,
'donate_link' => false,
'tags' => false,
'sections' => false,
'homepage' => false,
'added' => false,
'last_updated' => false,
'compatibility' => false,
'tested' => false,
'requires' => false,
'downloadlink' => false,
'icons' => false,
),
)
);
set_transient( 'cust_notice_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
}
return $call_api;
}
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
* @access public
* @return array
*/
public function json() {
$json = parent::json();
global $rara_business_recommended_plugins;
global $install_button_label;
global $activate_button_label;
global $deactivate_button_label;
$customize_plugins = array();
$show_recommended_plugins = get_option( 'rara_business_show_recommended_plugins' );
foreach ( $rara_business_recommended_plugins as $slug => $plugin_opt ) {
if ( ! $plugin_opt['recommended'] ) {
continue;
}
if ( isset( $show_recommended_plugins[ $slug ] ) && $show_recommended_plugins[ $slug ] ) {
continue;
}
$active = $this->check_active( $slug );
if ( ! empty( $active['needs'] ) && ( $active['needs'] == 'deactivate' ) ) {
continue;
}
$rara_business_recommended_plugin['url'] = $this->create_action_link( $active['needs'], $slug );
if ( $active['needs'] !== 'install' && $active['status'] ) {
$rara_business_recommended_plugin['class'] = 'active';
} else {
$rara_business_recommended_plugin['class'] = '';
}
switch ( $active['needs'] ) {
case 'install':
$rara_business_recommended_plugin['button_class'] = 'install-now button';
$rara_business_recommended_plugin['button_label'] = $install_button_label;
break;
case 'activate':
$rara_business_recommended_plugin['button_class'] = 'activate-now button button-primary';
$rara_business_recommended_plugin['button_label'] = $activate_button_label;
break;
case 'deactivate':
$rara_business_recommended_plugin['button_class'] = 'deactivate-now button';
$rara_business_recommended_plugin['button_label'] = $deactivate_button_label;
break;
}
$info = $this->call_plugin_api( $slug );
$rara_business_recommended_plugin['id'] = $slug;
$rara_business_recommended_plugin['plugin_slug'] = $slug;
if ( ! empty( $plugin_opt['description'] ) ) {
$rara_business_recommended_plugin['description'] = $plugin_opt['description'];
} else {
$rara_business_recommended_plugin['description'] = $info->short_description;
}
$rara_business_recommended_plugin['title'] = $info->name;
$customize_plugins[] = $rara_business_recommended_plugin;
}// End foreach().
$json['recommended_plugins'] = $customize_plugins;
$json['plugin_text'] = $this->plugin_text;
$json['dismiss_button'] = $this->dismiss_button;
return $json;
}
/**
* Outputs the structure for the customizer control
*
* @since 1.0.0
* @access public
* @return void
*/
protected function render_template() {
?>
<# if( data.recommended_plugins.length > 0 ){ #>
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
<span class="section-title" data-plugin_text="{{ data.plugin_text }}">
<# if( data.recommended_plugins.length > 0 ){ #>
{{ data.plugin_text }}
<# } #>
</span>
</h3>
<div class="recomended-actions_container" id="plugin-filter">
<# if( data.recommended_plugins.length > 0 ){ #>
<# for (action in data.recommended_plugins) { #>
<div class="rara-recommeded-actions-container rara-recommended-plugins" data-index="{{ data.recommended_plugins[action].index }}">
<# if( !data.recommended_plugins[action].check ){ #>
<div class="rara-recommeded-actions">
<p class="title">{{ data.recommended_plugins[action].title }}</p>
<span data-action="dismiss" class="dashicons dashicons-no dismiss-button-recommended-plugin" id="{{ data.recommended_plugins[action].id }}"></span>
<div class="description">{{{ data.recommended_plugins[action].description }}}</div>
<# if( data.recommended_plugins[action].plugin_slug ){ #>
<div class="custom-action">
<p class="plugin-card-{{ data.recommended_plugins[action].plugin_slug }} action_button {{ data.recommended_plugins[action].class }}">
<a data-slug="{{ data.recommended_plugins[action].plugin_slug }}"
class="{{ data.recommended_plugins[action].button_class }}"
href="{{ data.recommended_plugins[action].url }}">{{ data.recommended_plugins[action].button_label }}</a>
</p>
</div>
<# } #>
<# if( data.recommended_plugins[action].help ){ #>
<div class="custom-action">{{{ data.recommended_plugins[action].help }}}</div>
<# } #>
</div>
<# } #>
</div>
<# } #>
<# } #>
</div>
</li>
<# } #>
<?php
}
}

View File

@@ -0,0 +1,204 @@
<?php
/**
* Rara Business Customizer Notification System.
*
* @package Rara_Business
*/
/**
* TI Customizer Notify Class
*/
class Rara_Business_Customizer_Notice {
/**
* Recommended plugins
*
* @var array $recommended_plugins Recommended plugins displayed in customize notification system.
*/
private $recommended_plugins;
/**
* The single instance of Rara_Business_Customizer_Notice
*
* @var Rara_Business_Customizer_Notice $instance The Rara_Business_Customizer_Notice instance.
*/
private static $instance;
/**
* Title of Recommended plugins section in customize
*
* @var string $recommended_plugins_title Title of Recommended plugins section displayed in customize notification system.
*/
private $recommended_plugins_title;
/**
* Dismiss button label
*
* @var string $dismiss_button Dismiss button label displayed in customize notification system.
*/
private $dismiss_button;
/**
* Install button label for plugins
*
* @var string $install_button_label Label of install button for plugins displayed in customize notification system.
*/
private $install_button_label;
/**
* Activate button label for plugins
*
* @var string $activate_button_label Label of activate button for plugins displayed in customize notification system.
*/
private $activate_button_label;
/**
* Deactivate button label for plugins
*
* @var string $deactivate_button_label Label of deactivate button for plugins displayed in customize notification system.
*/
private $deactivate_button_label;
/**
* The Main Rara_Business_Customizer_Notice instance.
*
* We make sure that only one instance of Rara_Business_Customizer_Notice exists in the memory at one time.
*
* @param array $config The configuration array.
*/
public static function init( $config ) {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Rara_Business_Customizer_Notice ) ) {
self::$instance = new Rara_Business_Customizer_Notice;
if ( ! empty( $config ) && is_array( $config ) ) {
self::$instance->config = $config;
self::$instance->setup_config();
self::$instance->setup_actions();
}
}
}
/**
* Setup the class props based on the config array.
*/
public function setup_config() {
// global arrays for recommended plugins/actions
global $rara_business_recommended_plugins;
global $install_button_label;
global $activate_button_label;
global $deactivate_button_label;
$this->recommended_plugins = isset( $this->config['recommended_plugins'] ) ? $this->config['recommended_plugins'] : array();
$this->recommended_plugins_title = isset( $this->config['recommended_plugins_title'] ) ? $this->config['recommended_plugins_title'] : '';
$this->dismiss_button = isset( $this->config['dismiss_button'] ) ? $this->config['dismiss_button'] : '';
$rara_business_recommended_plugins = array();
if ( isset( $this->recommended_plugins ) ) {
$rara_business_recommended_plugins = $this->recommended_plugins;
}
$install_button_label = isset( $this->config['install_button_label'] ) ? $this->config['install_button_label'] : '';
$activate_button_label = isset( $this->config['activate_button_label'] ) ? $this->config['activate_button_label'] : '';
$deactivate_button_label = isset( $this->config['deactivate_button_label'] ) ? $this->config['deactivate_button_label'] : '';
}
/**
* Setup the actions used for this class.
*/
public function setup_actions() {
// Register the section
add_action( 'customize_register', array( $this, 'customize_register_notice' ) );
// Enqueue scripts and styles
add_action( 'customize_controls_enqueue_scripts', array( $this, 'scripts_for_customizer' ), 0 );
/* ajax callback for dismissable recommended plugins */
add_action( 'wp_ajax_dismiss_recommended_plugins', array( $this, 'dismiss_recommended_plugins_callback' ) );
}
/**
* Scripts and styles used in the Themeisle_Customizer_Notify class
*/
public function scripts_for_customizer() {
wp_enqueue_style( 'rara-business-customizer-notice', get_template_directory_uri() . '/inc/customizer-plugin-recommend/customizer-notice/css/customizer-notice.css', array(), RARA_BUSINESS_THEME_VERSION );
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
wp_add_inline_script( 'plugin-install', 'var pagenow = "customizer";' );
wp_enqueue_script( 'updates' );
wp_enqueue_script( 'rara-business-customizer-notice', get_template_directory_uri() . '/inc/customizer-plugin-recommend/customizer-notice/js/customizer-notice.js', array( 'customize-controls' ), RARA_BUSINESS_THEME_VERSION );
wp_localize_script(
'rara-business-customizer-notice', 'customizer_notice_data', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'template_directory' => get_template_directory_uri(),
'base_path' => admin_url(),
'activating_string' => __( 'Activating', 'rara-business' ),
)
);
}
/**
* Register the section for the recommended actions/plugins in customize
*
* @param object $wp_customize The customizer object.
*/
public function customize_register_notice( $wp_customize ) {
/**
* Include the Rara_Business_Customizer_Notice_Section class.
*/
require_once get_template_directory() . '/inc/customizer-plugin-recommend/customizer-notice/class-customizer-notice-section.php';
$wp_customize->register_section_type( 'Rara_Business_Customizer_Notice_Section' );
$wp_customize->add_section(
new Rara_Business_Customizer_Notice_Section(
$wp_customize,
'customizer-plugin-notice-section',
array(
'plugin_text' => $this->recommended_plugins_title,
'dismiss_button' => $this->dismiss_button,
'priority' => 0,
)
)
);
}
/**
* Dismiss recommended plugins
*/
public function dismiss_recommended_plugins_callback() {
$action_id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0;
echo esc_html( $action_id ); /* this is needed and it's the id of the dismissable required action */
if ( ! empty( $action_id ) ) {
/* if the option exists, update the record for the specified id */
$show_recommended_plugins = get_option( 'rara_business_show_recommended_plugins' );
switch ( $_GET['todo'] ) {
case 'add':
$show_recommended_plugins[ $action_id ] = false;
break;
case 'dismiss':
$show_recommended_plugins[ $action_id ] = true;
break;
}
update_option( 'rara_business_show_recommended_plugins', $show_recommended_plugins );
}
die(); // this is required to return a proper result
}
}

View File

@@ -0,0 +1,119 @@
div.recomended-actions_container {
margin-bottom: 2em;
padding: 0 10px;
}
.recomended-actions_container p.succes {
margin: 1em 0;
}
.rara-recommeded-actions p.title {
margin-bottom: 0;
color: #555d66;
font-size: 14px;
font-weight: 600;
}
.rara-recommeded-actions div.description {
font-size: 12px;
}
.rara-recommeded-actions .custom-action {
margin-top: 1em;
padding-top: 1em;
border-top: 1px solid #fafafa;
}
.rara-recommeded-actions .custom-action p {
margin-top: 0;
}
.recomended-actions_container .rara-recommeded-actions-container:not(:first-child) {
overflow: hidden;
height: 0;
opacity: 0;
}
.recomended-actions_container .rara-recommeded-actions-container:first-child {
height: auto;
opacity: 1;
}
.recomended-actions_container .rara-recommeded-actions-container {
-webkit-transition: opacity 2s;
/* Safari */
transition: opacity 2s;
}
.recomended-actions_container .hide {
display: none;
}
.recomended-actions_container #demo_content .button {
display: block;
margin-bottom: 1em;
text-align: center;
}
.recomended-actions_container .succes a {
display: inline-block;
width: 100%;
text-align: center;
}
.recomended-actions_container .succes a.social {
width: 49%;
margin-bottom: 1em;
padding-top: 4px;
line-height: 20px;
}
.recomended-actions_container .succes a.social span,
.recomended-actions_container .succes a.ti-customizer-notify-wordpress span {
margin-right: 5px;
}
.recomended-actions_container .succes a.ti-customizer-notify-wordpress {
padding-top: 4px;
line-height: 20px;
}
.dismiss-button-recommended-plugin {
position: absolute;
top: 10px;
right: 10px;
border-radius: 50%;
color: #d54e21;
text-decoration: none;
cursor: pointer;
}
.rara-recommeded-actions {
position: relative;
}
.rara-recommeded-actions .dismiss-button-recommended-plugin {
top: 0;
right: 0;
}
.rara-recommeded-actions #temp_load {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-align-items: center;
align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
}
.rara-recommeded-actions #temp_load img {
margin: 0 auto;
}

View File

@@ -0,0 +1,92 @@
/* global wp */
/* global customizer_notice_data */
/* global console */
(function (api) {
api.sectionConstructor['customizer-plugin-notice-section'] = api.Section.extend({
// No events for this type of section.
attachEvents: function () {
},
// Always make the section active.
isContextuallyActive: function () {
return true;
}
});
})(wp.customize);
jQuery(document).ready(function ($) {
$('.dismiss-button-recommended-plugin').click(function () {
var id = $(this).attr('id'),
action = $(this).attr('data-action');
$.ajax({
type: 'GET',
data: {action: 'dismiss_recommended_plugins', id: id, todo: action},
dataType: 'html',
url: customizer_notice_data.ajaxurl,
beforeSend: function () {
$('#' + id).parent().append('<div id="temp_load" style="text-align:center"><img src="' + customizer_notice_data.base_path + '/images/spinner-2x.gif" /></div>');
},
success: function (data) {
var container = $('#' + data).parent().parent();
container.slideToggle().remove();
if( $('.recomended-actions_container > .rara-recommended-plugins').length === 0 ){
$('.control-section-customizer-plugin-notice-section').remove();
}
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown);
}
});
});
// Remove activate button and replace with activation in progress button.
$('body').on('DOMNodeInserted', '.activate-now', function () {
var activateButton = $('.activate-now');
if( activateButton.length ){
var url = activateButton.attr('href');
if( typeof url !== 'undefined' ){
//Request plugin activation.
$.ajax({
beforeSend: function () {
activateButton.replaceWith('<a class="button updating-message">' + customizer_notice_data.activating_string + '...</a>');
},
async: true,
type: 'GET',
url: url,
success: function () {
//Reload the page.
location.reload();
}
});
}
}
});
$('.activate-now').on('click', function(e){
var activateButton = $(this);
e.preventDefault();
if (activateButton.length) {
var url = activateButton.attr('href');
if (typeof url !== 'undefined') {
//Request plugin activation.
$.ajax({
beforeSend: function () {
activateButton.replaceWith('<a class="button updating-message">' + customizer_notice_data.activating_string + '...</a>');
},
async: true,
type: 'GET',
url: url,
success: function () {
//Reload the page.
location.reload();
}
});
}
}
});
});

View File

@@ -0,0 +1,118 @@
<?php
/**
* Plugin install helper.
*
* @package Rara_Business
*/
/**
* Class Rara_Business_Plugin_Install_Helper
*/
class Rara_Business_Plugin_Install_Helper {
/**
* Instance of class.
*
* @var bool $instance instance variable.
*/
private static $instance;
/**
* Check if instance already exists.
*
* @return Rara_Business_Plugin_Install_Helper
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Rara_Business_Plugin_Install_Helper ) ) {
self::$instance = new Rara_Business_Plugin_Install_Helper;
}
return self::$instance;
}
/**
* Generate action button html.
*
* @param string $slug plugin slug.
*
* @return string
*/
public function get_button_html( $slug ) {
$button = '';
$state = $this->check_plugin_state( $slug );
if ( ! empty( $slug ) ) {
$button .= '<div class=" plugin-card-' . esc_attr( $slug ) . '" style="padding: 8px 0 5px;">';
switch ( $state ) {
case 'install':
$nonce = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'from' => 'import',
'plugin' => $slug,
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $slug
);
$button .= '<a data-slug="' . esc_attr( $slug ) . '" class="install-now ta-install-plugin button " href="' . esc_url( $nonce ) . '" data-name="' . esc_attr( $slug ) . '" aria-label="Install ' . esc_attr( $slug ) . '">' . __( 'Install and activate', 'rara-business' ) . '</a>';
break;
case 'activate':
$plugin_link_suffix = $slug . '/' . $slug . '.php';
$nonce = add_query_arg(
array(
'action' => 'activate',
'plugin' => rawurlencode( $plugin_link_suffix ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin_link_suffix ),
), network_admin_url( 'plugins.php' )
);
$button .= '<a data-slug="' . esc_attr( $slug ) . '" class="activate button button-primary" href="' . esc_url( $nonce ) . '" aria-label="Activate ' . esc_attr( $slug ) . '">' . __( 'Activate', 'rara-business' ) . '</a>';
break;
}// End switch().
$button .= '</div>';
}// End if().
return $button;
}
/**
* Check plugin state.
*
* @param string $slug plugin slug.
*
* @return bool
*/
private function check_plugin_state( $slug ) {
if ( file_exists( ABSPATH . 'wp-content/plugins/' . $slug . '/' . $slug . '.php' ) || file_exists( ABSPATH . 'wp-content/plugins/' . $slug . '/index.php' ) ) {
$needs = ( is_plugin_active( $slug . '/' . $slug . '.php' ) || is_plugin_active( $slug . '/index.php' ) ) ? 'deactivate' : 'activate';
return $needs;
} else {
return 'install';
}
}
/**
* Enqueue Function.
*/
public function enqueue_scripts() {
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
wp_enqueue_script( 'rara-business-plugin-install-helper', get_template_directory_uri() . '/inc/customizer-plugin-recommend/plugin-install/js/plugin-install.js', array( 'jquery' ), RARA_BUSINESS_THEME_VERSION, true );
wp_localize_script(
'rara-business-plugin-install-helper', 'plugin_helper',
array(
'activating' => esc_html__( 'Activating ', 'rara-business' ),
)
);
wp_localize_script(
'rara-business-plugin-install-helper', 'pagenow',
array( 'import' )
);
}
}

View File

@@ -0,0 +1,56 @@
/* global plugin_helper */
jQuery(document).ready(function ($) {
$('body').on('click', '.ta-install-plugin', function(){
var slug = $(this).attr('data-slug');
wp.updates.installPlugin({
slug: slug
});
return false;
});
//Remove activate button and replace with activation in progress button.
$('body').on('DOMNodeInserted', '.activate', function () {
var activateButton = $('.activate');
if( activateButton.length ) {
var url = activateButton.attr('href');
if( typeof url !== 'undefined' ){
//Request plugin activation.
$.ajax({
beforeSend: function () {
activateButton.replaceWith('<a class="button updating-message">' + plugin_helper.activating + '...</a>');
},
async: true,
type: 'GET',
url: url,
success: function () {
//Reload the page.
location.reload();
}
});
}
}
});
$('.activate').on('click', function (e) {
var activateButton = $(this);
e.preventDefault();
if( activateButton.length ){
var url = activateButton.attr('href');
if( typeof url !== 'undefined' ){
//Request plugin activation.
$.ajax({
beforeSend: function () {
activateButton.replaceWith('<a class="button updating-message">' + plugin_helper.activating + '...</a>');
},
async: true,
type: 'GET',
url: url,
success: function () {
//Reload the page.
location.reload();
}
});
}
}
});
});

View File

@@ -0,0 +1,97 @@
<?php
/**
* Rara Business Theme Customizer
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register' ) ) :
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function rara_business_customize_register( $wp_customize ) {
$wp_customize->get_section( 'background_image' )->priority = 40;
}
endif;
add_action( 'customize_register', 'rara_business_customize_register' );
$rara_business_panels = array( 'frontpage', 'general', 'appearance' );
$rara_business_sections = array( 'info', 'demo-content', 'site-identity', 'footer' );
$rara_business_sub_sections = array(
'frontpage' => array( 'banner', 'portfolio', 'blog' ),
'general' => array( 'header', 'seo', 'post-page','misc' ),
);
foreach( $rara_business_panels as $p ){
require get_template_directory() . '/inc/customizer/panels/' . $p . '.php';
}
foreach( $rara_business_sections as $section ){
require get_template_directory() . '/inc/customizer/sections/' . $section . '.php';
}
foreach( $rara_business_sub_sections as $k => $v ){
foreach( $v as $w ){
require get_template_directory() . '/inc/customizer/panels/' . $k . '/' . $w . '.php';
}
}
if ( ! function_exists( 'rara_business_customize_preview_js' ) ) :
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function rara_business_customize_preview_js() {
wp_enqueue_script( 'rara-business-customizer', get_template_directory_uri() . '/js/build/customizer.js', array( 'customize-preview' ), '20151215', true );
}
endif;
add_action( 'customize_preview_init', 'rara_business_customize_preview_js' );
if ( ! function_exists( 'rara_business_customizer_script' ) ) :
/**
* Customizer Scripts
*/
function rara_business_customizer_script(){
$array = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'flushit' => __( 'Successfully Flushed!','rara-business' ),
'nonce' => wp_create_nonce('ajax-nonce')
);
wp_enqueue_style( 'rara-business-customize-controls', get_template_directory_uri() . '/inc/css/customize-controls.css', array(), false , 'screen' );
wp_enqueue_script( 'rara-business-customize-controls', get_template_directory_uri() . '/inc/js/customize-controls.js', array( 'jquery', 'customize-controls' ), false, true );
wp_localize_script( 'rara-business-customize-controls', 'rara_business_cdata', $array );
wp_localize_script( 'rara-business-repeater', 'rara_business_customize',
array(
'nonce' => wp_create_nonce( 'rara_business_customize_nonce' )
)
);
}
endif;
add_action( 'customize_controls_enqueue_scripts', 'rara_business_customizer_script' );
/*
* Notifications in customizer
*/
require get_template_directory() . '/inc/customizer-plugin-recommend/customizer-notice/class-customizer-notice.php';
require get_template_directory() . '/inc/customizer-plugin-recommend/plugin-install/class-plugin-install-helper.php';
$config_customizer = array(
'recommended_plugins' => array(
'raratheme-companion' => array(
'recommended' => true,
'description' => sprintf(
/* translators: %s: plugin name */
esc_html__( 'If you want to take full advantage of the features this theme has to offer, please install and activate %s plugin.', 'rara-business' ), '<strong>RaraTheme Companion</strong>'
),
),
),
'recommended_plugins_title' => esc_html__( 'Recommended Plugin', 'rara-business' ),
'install_button_label' => esc_html__( 'Install and Activate', 'rara-business' ),
'activate_button_label' => esc_html__( 'Activate', 'rara-business' ),
'deactivate_button_label' => esc_html__( 'Deactivate', 'rara-business' ),
);
Rara_Business_Customizer_Notice::init( apply_filters( 'rara_business_customizer_notice_array', $config_customizer ) );

View File

@@ -0,0 +1,71 @@
<?php
/**
* Rara Business Theme Customizer Default Value.
*
* @package Rara_Business
*/
function rara_business_default_theme_options() {
$default_options = array(
// Header section
'ed_header_contact_details' => true,
'header_phone' => '',
'header_address' => '',
'header_email' => '',
'custom_link_icon' => 'fa fa-edit',
'custom_link_label' => '',
'custom_link' => '',
// Social media section
'ed_header_social_links' => true,
'header_social_links' => array(),
// Seo section
'ed_post_update_date' => true,
'ed_breadcrumb' => true,
'home_text' => __( 'Home', 'rara-business' ),
// Post/Page section
'page_sidebar_layout' => 'right-sidebar',
'post_sidebar_layout' => 'right-sidebar',
'ed_excerpt' => true,
'excerpt_length' => '55',
'read_more_text' => __( 'Read More', 'rara-business' ),
'post_note_text' => '',
'ed_author' => false,
'ed_related' => true,
'related_post_title' => __( 'You may also like...', 'rara-business' ),
'ed_popular_posts' => true,
'popular_post_title' => __( 'Popular Posts', 'rara-business' ),
'ed_post_date_meta' => false,
'ed_post_author_meta' => false,
'ed_featured_image' => true,
'ed_animation' => true,
'ed_prefix_archive' => false,
// Banner section
'ed_banner_section' => 'static_banner',
'banner_title' => __( 'Perfectionist at Every Level', 'rara-business' ),
'banner_description' => __( 'Believing in the possibility of attaining perfection.', 'rara-business' ),
'banner_link_one_label' => __( 'Free Inquiry', 'rara-business' ),
'banner_link_one_url' => '#',
'banner_link_two_label' => __( 'View Services', 'rara-business' ),
'banner_link_two_url' => '#',
// Portfolio section
'ed_portfolio_section' => true,
'portfolio_title' => __( 'Our Case Studies', 'rara-business' ),
'portfolio_description' => __( 'It looks perfect on all major browsers, tablets and phones. The kind of product you are looking for.', 'rara-business' ),
'portfolio_no_of_posts' => '10',
// Blog section
'ed_blog_section' => true,
'blog_title' => __( 'Our Blog', 'rara-business' ),
'blog_description' => __( 'It looks perfect on all major browsers, tablets and phones. The kind of product you are looking for.', 'rara-business' ),
);
$output = apply_filters( 'rara_business_default_theme_options', $default_options );
return $output;
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Appearance Setting Panel
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_appearance_settings_panel' ) ) :
/**
* Add appearance settings panel
*/
function rara_business_customize_register_appearance_settings_panel( $wp_customize ) {
$wp_customize->add_panel( 'appearance_settings_panel', array(
'title' => __( 'Appearance Settings', 'rara-business' ),
'priority' => 60,
'capability' => 'edit_theme_options',
) );
/** Typography */
$wp_customize->add_section(
'typography_settings',
array(
'title' => __( 'Typography', 'rara-business' ),
'priority' => 70,
'panel' => 'appearance_settings',
)
);
$wp_customize->add_setting(
'ed_localgoogle_fonts',
array(
'default' => false,
'sanitize_callback' => 'rara_business_sanitize_checkbox',
)
);
$wp_customize->add_control(
'ed_localgoogle_fonts',
array(
'label' => __( 'Load Google Fonts Locally', 'rara-business' ),
'section' => 'typography_settings',
'type' => 'checkbox',
)
);
$wp_customize->add_setting(
'ed_preload_local_fonts',
array(
'default' => false,
'sanitize_callback' => 'rara_business_sanitize_checkbox',
)
);
$wp_customize->add_control(
'ed_preload_local_fonts',
array(
'label' => __( 'Preload Local Fonts', 'rara-business' ),
'section' => 'typography_settings',
'type' => 'checkbox',
'active_callback' => 'rara_business_flush_fonts_callback'
)
);
$wp_customize->add_setting(
'flush_google_fonts',
array(
'default' => '',
'sanitize_callback' => 'wp_kses',
)
);
$wp_customize->add_control(
'flush_google_fonts',
array(
'label' => __( 'Flush Local Fonts Cache', 'rara-business' ),
'description' => __( 'Click the button to reset the local fonts cache.', 'rara-business' ),
'type' => 'button',
'settings' => array(),
'section' => 'typography_settings',
'input_attrs' => array(
'value' => __( 'Flush Local Fonts Cache', 'rara-business' ),
'class' => 'button button-primary flush-it',
),
'active_callback' => 'rara_business_flush_fonts_callback'
)
);
// Move default section to apperance settings panel
$wp_customize->get_section( 'background_image' )->panel = 'appearance_settings_panel';
$wp_customize->get_section( 'colors' )->panel = 'appearance_settings_panel';
$wp_customize->get_section( 'typography_settings' )->panel = 'appearance_settings_panel';
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_appearance_settings_panel' );
function rara_business_flush_fonts_callback( $control ){
$ed_localgoogle_fonts = $control->manager->get_setting( 'ed_localgoogle_fonts' )->value();
$control_id = $control->id;
if ( $control_id == 'flush_google_fonts' && $ed_localgoogle_fonts ) return true;
if ( $control_id == 'ed_preload_local_fonts' && $ed_localgoogle_fonts ) return true;
return false;
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* Front Page Panel
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_frontpage_panel' ) ) :
/**
* Add frontpage panel
*/
function rara_business_customize_register_frontpage_panel( $wp_customize ) {
$wp_customize->add_panel( 'frontpage_panel', array(
'title' => __( 'Frontpage Settings', 'rara-business' ),
'priority' => 60,
'capability' => 'edit_theme_options',
) );
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_frontpage_panel' );

View File

@@ -0,0 +1,227 @@
<?php
/**
* Banner Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_banner_section' ) ) :
/**
* Add banner section controls
*/
function rara_business_customize_register_banner_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$wp_customize->get_section( 'header_image' )->panel = 'frontpage_panel';
$wp_customize->get_section( 'header_image' )->title = __( 'Banner Section', 'rara-business' );
$wp_customize->get_section( 'header_image' )->priority = 10;
$wp_customize->get_control( 'header_image' )->active_callback = 'rara_business_banner_ac';
$wp_customize->get_control( 'header_video' )->active_callback = 'rara_business_banner_ac';
$wp_customize->get_control( 'external_header_video' )->active_callback = 'rara_business_banner_ac';
$wp_customize->get_section( 'header_image' )->description = '';
$wp_customize->get_setting( 'header_image' )->transport = 'refresh';
$wp_customize->get_setting( 'header_video' )->transport = 'refresh';
$wp_customize->get_setting( 'external_header_video' )->transport = 'refresh';
/** Banner Options */
$wp_customize->add_setting(
'ed_banner_section',
array(
'default' => $default_options['ed_banner_section'],
'sanitize_callback' => 'rara_business_sanitize_select'
)
);
$wp_customize->add_control(
new Rara_Business_Select_Control(
$wp_customize,
'ed_banner_section',
array(
'label' => __( 'Banner Options', 'rara-business' ),
'description' => __( 'Choose banner as static image/video.', 'rara-business' ),
'section' => 'header_image',
'choices' => array(
'no_banner' => __( 'Disable Banner Section', 'rara-business' ),
'static_banner' => __( 'Static/Video Banner', 'rara-business' ),
),
'priority' => 5
)
)
);
/** Banner title */
$wp_customize->add_setting(
'banner_title',
array(
'default' => $default_options['banner_title'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'banner_title',
array(
'section' => 'header_image',
'label' => __( 'Banner Title', 'rara-business' ),
'active_callback' => 'rara_business_banner_ac'
)
);
// banner title selective refresh
$wp_customize->selective_refresh->add_partial( 'banner_title', array(
'selector' => '.banner .text-holder h2.title',
'render_callback' => 'rara_business_banner_title_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Banner description */
$wp_customize->add_setting(
'banner_description',
array(
'default' => $default_options['banner_description'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'banner_description',
array(
'section' => 'header_image',
'label' => __( 'Banner Description', 'rara-business' ),
'active_callback' => 'rara_business_banner_ac'
)
);
// Banner description selective refresh
$wp_customize->selective_refresh->add_partial( 'banner_description', array(
'selector' => '.banner .text-holder p',
'render_callback' => 'rara_business_banner_description_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Banner link one label */
$wp_customize->add_setting(
'banner_link_one_label',
array(
'default' => $default_options['banner_link_one_label'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'banner_link_one_label',
array(
'section' => 'header_image',
'label' => __( 'Link One Label', 'rara-business' ),
'active_callback' => 'rara_business_banner_ac'
)
);
// Selective refresh for banner link one label
$wp_customize->selective_refresh->add_partial( 'banner_link_one_label', array(
'selector' => '.banner .btn-holder a.btn-free-inquiry',
'render_callback' => 'rara_business_banner_link_one_label_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Banner link one url */
$wp_customize->add_setting(
'banner_link_one_url',
array(
'default' => $default_options['banner_link_one_url'],
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'banner_link_one_url',
array(
'section' => 'header_image',
'label' => __( 'Link One Url', 'rara-business' ),
'type' => 'url',
'active_callback' => 'rara_business_banner_ac'
)
);
/** Banner link two label */
$wp_customize->add_setting(
'banner_link_two_label',
array(
'default' => $default_options['banner_link_two_label'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'banner_link_two_label',
array(
'section' => 'header_image',
'label' => __( 'Link Two Label', 'rara-business' ),
'active_callback' => 'rara_business_banner_ac'
)
);
// Selective refresh for banner link two label.
$wp_customize->selective_refresh->add_partial( 'banner_link_two_label', array(
'selector' => '.banner .btn-holder a.btn-view-service',
'render_callback' => 'rara_business_banner_link_two_label_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Banner link two url */
$wp_customize->add_setting(
'banner_link_two_url',
array(
'default' => $default_options['banner_link_two_url'],
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'banner_link_two_url',
array(
'section' => 'header_image',
'label' => __( 'Link Two Url', 'rara-business' ),
'type' => 'url',
'active_callback' => 'rara_business_banner_ac'
)
);
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_banner_section' );
if ( ! function_exists( 'rara_business_banner_ac' ) ) :
/**
* Active Callback
*/
function rara_business_banner_ac( $control ){
$banner = $control->manager->get_setting( 'ed_banner_section' )->value();
$control_id = $control->id;
// static banner controls
if ( $control_id == 'header_image' && $banner == 'static_banner' ) return true;
if ( $control_id == 'header_video' && $banner == 'static_banner' ) return true;
if ( $control_id == 'external_header_video' && $banner == 'static_banner' ) return true;
// banner title and description controls
if ( $control_id == 'banner_title' && $banner == 'static_banner' ) return true;
if ( $control_id == 'banner_description' && $banner == 'static_banner' ) return true;
// Link button controls
if ( $control_id == 'banner_link_one_label' && $banner == 'static_banner' ) return true;
if ( $control_id == 'banner_link_one_url' && $banner == 'static_banner' ) return true;
if ( $control_id == 'banner_link_two_label' && $banner == 'static_banner' ) return true;
if ( $control_id == 'banner_link_two_url' && $banner == 'static_banner' ) return true;
return false;
}
endif;

View File

@@ -0,0 +1,119 @@
<?php
/**
* Blog Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_blog_section' ) ) :
/**
* Add blog section controls
*/
function rara_business_customize_register_blog_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Blog Sectopm */
$wp_customize->add_section(
'blog_section',
array(
'title' => __( 'Blog Section', 'rara-business' ),
'priority' => 77,
'panel' => 'frontpage_panel',
)
);
/** Blog Options */
$wp_customize->add_setting(
'ed_blog_section',
array(
'default' => $default_options['ed_blog_section'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_blog_section',
array(
'label' => __( 'Enable Blog Section', 'rara-business' ),
'description' => __( 'Enable to show blog section.', 'rara-business' ),
'section' => 'blog_section',
'priority' => 5
)
)
);
/** Blog title */
$wp_customize->add_setting(
'blog_title',
array(
'default' => $default_options['blog_title'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'blog_title',
array(
'section' => 'blog_section',
'label' => __( 'Blog Title', 'rara-business' ),
'active_callback' => 'rara_business_blog_ac'
)
);
// Selective refresh for blog title.
$wp_customize->selective_refresh->add_partial( 'blog_title', array(
'selector' => '.blog-section .widget_text h2.widget-title',
'render_callback' => 'rara_business_blog_title_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Blog description */
$wp_customize->add_setting(
'blog_description',
array(
'default' => $default_options['blog_description'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'blog_description',
array(
'section' => 'blog_section',
'label' => __( 'Blog Description', 'rara-business' ),
'active_callback' => 'rara_business_blog_ac'
)
);
// Selective refresh for blog description.
$wp_customize->selective_refresh->add_partial( 'blog_description', array(
'selector' => '.blog-section .textwidget p',
'render_callback' => 'rara_business_blog_description_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_blog_section' );
if ( ! function_exists( 'rara_business_blog_ac' ) ) :
/**
* Active Callback
*/
function rara_business_blog_ac( $control ){
$show_blog = $control->manager->get_setting( 'ed_blog_section' )->value();
$control_id = $control->id;
// Blog title, description and number of posts controls
if ( $control_id == 'blog_title' && $show_blog ) return true;
if ( $control_id == 'blog_description' && $show_blog ) return true;
return false;
}
endif;

View File

@@ -0,0 +1,168 @@
<?php
/**
* Portfolio Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_portfolio_section' ) ) :
/**
* Add portfolio section controls
*/
function rara_business_customize_register_portfolio_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Portfolio Section */
$wp_customize->add_section(
'portfolio_section',
array(
'title' => __( 'Portfolio Section', 'rara-business' ),
'priority' => 77,
'panel' => 'frontpage_panel',
)
);
/** Portfolio Options */
$wp_customize->add_setting(
'ed_portfolio_section',
array(
'default' => $default_options['ed_portfolio_section'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_portfolio_section',
array(
'label' => __( 'Enable Portfolio Section', 'rara-business' ),
'description' => __( 'Enable to show portfolio section.', 'rara-business' ),
'section' => 'portfolio_section',
'priority' => 5
)
)
);
if ( rara_business_is_rara_theme_companion_activated() ) {
/** Portfolio title */
$wp_customize->add_setting(
'portfolio_title',
array(
'default' => $default_options['portfolio_title'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'portfolio_title',
array(
'section' => 'portfolio_section',
'label' => __( 'Portfolio Title', 'rara-business' ),
'active_callback' => 'rara_business_portfolio_ac'
)
);
// Selective refresh for portfolio title.
$wp_customize->selective_refresh->add_partial( 'portfolio_title', array(
'selector' => '.portfolio .widget_text h2.widget-title',
'render_callback' => 'rara_business_portfolio_title_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Portfolio description */
$wp_customize->add_setting(
'portfolio_description',
array(
'default' => $default_options['portfolio_description'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'portfolio_description',
array(
'section' => 'portfolio_section',
'label' => __( 'Portfolio Description', 'rara-business' ),
'active_callback' => 'rara_business_portfolio_ac'
)
);
// Selective refresh for portfolio description.
$wp_customize->selective_refresh->add_partial( 'portfolio_description', array(
'selector' => '.portfolio .textwidget p',
'render_callback' => 'rara_business_portfolio_description_selective_refresh',
'container_inclusive' => false,
'fallback_refresh' => true,
) );
/** Number Of Portfolio Posts */
$wp_customize->add_setting(
'portfolio_no_of_posts',
array(
'default' => $default_options['portfolio_no_of_posts'],
'sanitize_callback' => 'rara_business_sanitize_select'
)
);
$wp_customize->add_control(
new Rara_Business_Select_Control(
$wp_customize,
'portfolio_no_of_posts',
array(
'label' => __( 'Number of Posts', 'rara-business' ),
'description' => __( 'Choose number of portfolio posts to be displayed.', 'rara-business' ),
'section' => 'portfolio_section',
'choices' => array(
'5' => __( '5', 'rara-business' ),
'10' => __( '10', 'rara-business' ),
),
'active_callback' => 'rara_business_portfolio_ac'
)
)
);
} else {
/** Activate RaraTheme Companion Plugin Note */
$wp_customize->add_setting(
'portfolio_note',
array(
'sanitize_callback' => 'wp_kses_post'
)
);
$wp_customize->add_control(
new Rara_Business_Note_Control(
$wp_customize,
'portfolio_note',
array(
'section' => 'portfolio_section',
/* translators: 1: link start, 2: link close */
'description' => sprintf( __( 'Please install and activate the recommended plugin %1$sRaraTheme Companion%2$s.', 'rara-business' ), '<a href="' . esc_url( admin_url( 'themes.php?page=tgmpa-install-plugins' ) ) . '" target="_blank">', '</a>' ),
)
)
);
}
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_portfolio_section' );
if ( ! function_exists( 'rara_business_portfolio_ac' ) ) :
/**
* Active Callback
*/
function rara_business_portfolio_ac( $control ){
$show_portfolio = $control->manager->get_setting( 'ed_portfolio_section' )->value();
$control_id = $control->id;
// Portfolio title, description and number of posts controls
if ( $control_id == 'portfolio_title' && $show_portfolio ) return true;
if ( $control_id == 'portfolio_description' && $show_portfolio ) return true;
if ( $control_id == 'portfolio_no_of_posts' && $show_portfolio ) return true;
return false;
}
endif;

View File

@@ -0,0 +1,22 @@
<?php
/**
* General Setting Panel
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_general_settings_panel' ) ) :
/**
* Add general settings panel
*/
function rara_business_customize_register_general_settings_panel( $wp_customize ) {
$wp_customize->add_panel( 'general_settings_panel', array(
'title' => __( 'General Settings', 'rara-business' ),
'priority' => 60,
'capability' => 'edit_theme_options',
) );
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_general_settings_panel' );

View File

@@ -0,0 +1,272 @@
<?php
/**
* Header Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_header_section' ) ) :
/**
* Add header section controls
*/
function rara_business_customize_register_header_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Header Section */
$wp_customize->add_section(
'header_section',
array(
'title' => __( 'Header Section', 'rara-business' ),
'priority' => 10,
'panel' => 'general_settings_panel',
)
);
/** Enable header top section */
$wp_customize->add_setting(
'ed_header_contact_details',
array(
'default' => $default_options['ed_header_contact_details'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_header_contact_details',
array(
'section' => 'header_section',
'label' => __( 'Enable Header Contact Details', 'rara-business' ),
'description' => __( 'Enable to show contact details in header top section.', 'rara-business' ),
)
)
);
/** Phone number */
$wp_customize->add_setting(
'header_phone',
array(
'default' => $default_options['header_phone'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->selective_refresh->add_partial( 'header_phone', array(
'selector' => '.header-t .phone a.tel-link',
'render_callback' => 'rara_business_header_phone_selective_refresh',
) );
$wp_customize->add_control(
'header_phone',
array(
'label' => __( 'Phone Number', 'rara-business' ),
'description' => __( 'Add phone no. in header.', 'rara-business' ),
'section' => 'header_section',
'type' => 'text',
'active_callback' => 'rara_business_header_top_section_ac'
)
);
/** Address */
$wp_customize->add_setting(
'header_address',
array(
'default' => $default_options['header_address'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->selective_refresh->add_partial( 'header_address', array(
'selector' => '.header-t .address address',
'render_callback' => 'rara_business_header_address_selective_refresh',
) );
$wp_customize->add_control(
'header_address',
array(
'label' => __( 'Address', 'rara-business' ),
'description' => __( 'Add address in header.', 'rara-business' ),
'section' => 'header_section',
'type' => 'text',
'active_callback' => 'rara_business_header_top_section_ac'
)
);
/** Email */
$wp_customize->add_setting(
'header_email',
array(
'default' => $default_options['header_email'],
'sanitize_callback' => 'sanitize_email',
'transport' => 'postMessage'
)
);
$wp_customize->selective_refresh->add_partial( 'header_email', array(
'selector' => '.header-t .email a.email-link',
'render_callback' => 'rara_business_header_email_selective_refresh',
) );
$wp_customize->add_control(
'header_email',
array(
'label' => __( 'Email', 'rara-business' ),
'description' => __( 'Add email in header.', 'rara-business' ),
'section' => 'header_section',
'type' => 'text',
'active_callback' => 'rara_business_header_top_section_ac'
)
);
/** Enable Social Links */
$wp_customize->add_setting(
'ed_header_social_links',
array(
'default' => $default_options['ed_header_social_links'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_header_social_links',
array(
'section' => 'header_section',
'label' => __( 'Enable Social Links', 'rara-business' ),
'description' => __( 'Enable to show social links at header.', 'rara-business' ),
)
)
);
$wp_customize->add_setting(
new Rara_Business_Repeater_Setting(
$wp_customize,
'header_social_links',
array(
'default' => $default_options['header_social_links'],
'sanitize_callback' => array( 'Rara_Business_Repeater_Setting', 'sanitize_repeater_setting' ),
)
)
);
$wp_customize->add_control(
new Rara_Business_Control_Repeater(
$wp_customize,
'header_social_links',
array(
'section' => 'header_section',
'label' => __( 'Social Links', 'rara-business' ),
'fields' => array(
'font' => array(
'type' => 'font',
'label' => __( 'Font Awesome Icon', 'rara-business' ),
'description' => __( 'Example: fa-bell', 'rara-business' ),
),
'link' => array(
'type' => 'url',
'label' => __( 'Link', 'rara-business' ),
'description' => __( 'Example: http://facebook.com', 'rara-business' ),
)
),
'row_label' => array(
'type' => 'field',
'value' => __( 'links', 'rara-business' ),
'field' => 'link'
),
'choices' => array(
'limit' => 10
),
'active_callback' => 'rara_business_header_top_section_ac',
)
)
);
/** Custom Link Icon */
$wp_customize->add_setting(
'custom_link_icon',
array(
'default' => $default_options['custom_link_icon'],
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
'custom_link_icon',
array(
'type' => 'font',
'label' => __( 'Custom Link Icon', 'rara-business' ),
'description' => __( 'Insert Icon eg. fa fa-edit.', 'rara-business' ),
'section' => 'header_section',
)
);
/** Custom Link label */
$wp_customize->add_setting(
'custom_link_label',
array(
'default' => $default_options['custom_link_label'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->selective_refresh->add_partial( 'custom_link_label', array(
'selector' => '.main-header .right .btn-buy',
'render_callback' => 'rara_business_header_custom_link_label_selective_refresh',
) );
$wp_customize->add_control(
'custom_link_label',
array(
'label' => __( 'Custom Link Label', 'rara-business' ),
'description' => __( 'Add cutom link button label in header.', 'rara-business' ),
'section' => 'header_section',
'type' => 'text',
)
);
/** Custom Link */
$wp_customize->add_setting(
'custom_link',
array(
'default' => $default_options['custom_link'],
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'custom_link',
array(
'label' => __( 'Custom link', 'rara-business' ),
'description' => __( 'Add custom link in header.', 'rara-business' ),
'section' => 'header_section',
'type' => 'url',
)
);
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_header_section' );
if ( ! function_exists( 'rara_business_header_top_section_ac' ) ) :
/**
* Active Callback
*/
function rara_business_header_top_section_ac( $control ){
$ed_header_top = $control->manager->get_setting( 'ed_header_contact_details' )->value();
$social_media_control = $control->manager->get_setting( 'ed_header_social_links' )->value();
$control_id = $control->id;
// Phone number, Address, Email and Custom Link controls
if ( $control_id == 'header_phone' && $ed_header_top ) return true;
if ( $control_id == 'header_address' && $ed_header_top ) return true;
if ( $control_id == 'header_email' && $ed_header_top ) return true;
if ( $control_id == 'header_social_links' && $social_media_control ) return true;
return false;
}
endif;

View File

@@ -0,0 +1,50 @@
<?php
/**
* Misc Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_misc_section' ) ) :
/**
* Add social media section controls
*/
function rara_business_customize_register_misc_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Misc Settings */
$wp_customize->add_section(
'misc_settings',
array(
'title' => __( 'Misc Settings', 'rara-business' ),
'priority' => 50,
'panel' => 'general_settings_panel',
)
);
/** Show Animation */
$wp_customize->add_setting(
'ed_animation',
array(
'default' => $default_options['ed_animation'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_animation',
array(
'section' => 'misc_settings',
'label' => __( 'Enable Animation', 'rara-business' ),
'description' => __( 'Enable/Disable Animation on the theme', 'rara-business' ),
)
)
);
/** Misc Settings Ends */
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_misc_section' );

View File

@@ -0,0 +1,384 @@
<?php
/**
* Post and Page Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_post_page_section' ) ) :
/**
* Add social media section controls
*/
function rara_business_customize_register_post_page_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Posts(Blog) & Pages Settings */
$wp_customize->add_section(
'post_page_settings',
array(
'title' => __( 'Posts(Blog) & Pages Settings', 'rara-business' ),
'priority' => 40,
'panel' => 'general_settings_panel',
)
);
/** Page Sidebar layout */
$wp_customize->add_setting(
'page_sidebar_layout',
array(
'default' => $default_options['page_sidebar_layout'],
'sanitize_callback' => 'rara_business_sanitize_radio'
)
);
$wp_customize->add_control(
new Rara_Business_Radio_Image_Control(
$wp_customize,
'page_sidebar_layout',
array(
'section' => 'post_page_settings',
'label' => __( 'Page Sidebar Layout', 'rara-business' ),
'description' => __( 'This is the general sidebar layout for pages. You can override the sidebar layout for individual page in repective page.', 'rara-business' ),
'choices' => array(
'no-sidebar' => get_template_directory_uri() . '/images/no-sidebar.png',
'left-sidebar' => get_template_directory_uri() . '/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/images/right-sidebar.png',
)
)
)
);
/** Post Sidebar layout */
$wp_customize->add_setting(
'post_sidebar_layout',
array(
'default' => $default_options['post_sidebar_layout'],
'sanitize_callback' => 'rara_business_sanitize_radio'
)
);
$wp_customize->add_control(
new Rara_Business_Radio_Image_Control(
$wp_customize,
'post_sidebar_layout',
array(
'section' => 'post_page_settings',
'label' => __( 'Post Sidebar Layout', 'rara-business' ),
'description' => __( 'This is the general sidebar layout for posts. You can override the sidebar layout for individual post in repective post.', 'rara-business' ),
'choices' => array(
'no-sidebar' => get_template_directory_uri() . '/images/no-sidebar.png',
'left-sidebar' => get_template_directory_uri() . '/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/images/right-sidebar.png',
)
)
)
);
/** Blog Excerpt */
$wp_customize->add_setting(
'ed_excerpt',
array(
'default' => $default_options['ed_excerpt'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_excerpt',
array(
'section' => 'post_page_settings',
'label' => __( 'Enable Blog Excerpt', 'rara-business' ),
'description' => __( 'Enable to show excerpt or disable to show full post content.', 'rara-business' ),
)
)
);
/** Excerpt Length */
$wp_customize->add_setting(
'excerpt_length',
array(
'default' => $default_options['excerpt_length'],
'sanitize_callback' => 'rara_business_sanitize_number_absint'
)
);
$wp_customize->add_control(
new Rara_Business_Slider_Control(
$wp_customize,
'excerpt_length',
array(
'section' => 'post_page_settings',
'label' => __( 'Excerpt Length', 'rara-business' ),
'description' => __( 'Automatically generated excerpt length (in words).', 'rara-business' ),
'choices' => array(
'min' => 10,
'max' => 100,
'step' => 5,
)
)
)
);
/** Read More Text */
$wp_customize->add_setting(
'read_more_text',
array(
'default' => $default_options['read_more_text'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'read_more_text',
array(
'type' => 'text',
'section' => 'post_page_settings',
'label' => __( 'Read More Text', 'rara-business' ),
)
);
$wp_customize->selective_refresh->add_partial( 'read_more_text', array(
'selector' => '.entry-footer a.btn-readmore',
'render_callback' => 'rara_business_readmore_label_selective_refresh',
) );
/** Hide Posted Date */
$wp_customize->add_setting(
'ed_post_date_meta',
array(
'default' => $default_options['ed_post_date_meta'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_post_date_meta',
array(
'section' => 'post_page_settings',
'label' => __( 'Hide Posted Date Meta', 'rara-business' ),
'description' => __( 'Enable to hide posted date.', 'rara-business' ),
)
)
);
/** Hide Posted Date */
$wp_customize->add_setting(
'ed_post_author_meta',
array(
'default' => $default_options['ed_post_author_meta'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_post_author_meta',
array(
'section' => 'post_page_settings',
'label' => __( 'Hide Author Meta', 'rara-business' ),
'description' => __( 'Enable to hide author meta.', 'rara-business' ),
)
)
);
/** Prefix Archive Page */
$wp_customize->add_setting(
'ed_prefix_archive',
array(
'default' => $default_options['ed_prefix_archive'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_prefix_archive',
array(
'section' => 'post_page_settings',
'label' => __( 'Hide Prefix in Archive Page', 'rara-business' ),
'description' => __( 'Enable to hide prefix in archive page.', 'rara-business' ),
)
)
);
/** Note */
$wp_customize->add_setting(
'post_note_text',
array(
'default' => $default_options['post_note_text'],
'sanitize_callback' => 'wp_kses_post'
)
);
$wp_customize->add_control(
new Rara_Business_Note_Control(
$wp_customize,
'post_note_text',
array(
'section' => 'post_page_settings',
'description' => __( '<hr/>These options affect your individual posts.', 'rara-business' ),
)
)
);
/** Hide Author */
$wp_customize->add_setting(
'ed_author',
array(
'default' => $default_options['ed_author'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_author',
array(
'section' => 'post_page_settings',
'label' => __( 'Hide Author', 'rara-business' ),
'description' => __( 'Enable to hide author section.', 'rara-business' ),
)
)
);
/** Show Related Posts */
$wp_customize->add_setting(
'ed_related',
array(
'default' => $default_options['ed_related'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_related',
array(
'section' => 'post_page_settings',
'label' => __( 'Show Related Posts', 'rara-business' ),
'description' => __( 'Enable to show related posts in single page.', 'rara-business' ),
)
)
);
/** Related Posts section title */
$wp_customize->add_setting(
'related_post_title',
array(
'default' => $default_options['related_post_title'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'related_post_title',
array(
'type' => 'text',
'section' => 'post_page_settings',
'label' => __( 'Related Posts Section Title', 'rara-business' ),
'active_callback' => 'rara_business_page_post_section_ac'
)
);
$wp_customize->selective_refresh->add_partial( 'related_post_title', array(
'selector' => '.related-post h2.section-title',
'render_callback' => 'rara_business_related_post_section_title_selective_refresh',
) );
/** Show Popular Posts */
$wp_customize->add_setting(
'ed_popular_posts',
array(
'default' => $default_options['ed_popular_posts'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_popular_posts',
array(
'section' => 'post_page_settings',
'label' => __( 'Show Popular Posts', 'rara-business' ),
'description' => __( 'Enable to show popular posts in single page.', 'rara-business' ),
)
)
);
/** Popular Posts section title */
$wp_customize->add_setting(
'popular_post_title',
array(
'default' => $default_options['popular_post_title'],
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'popular_post_title',
array(
'type' => 'text',
'section' => 'post_page_settings',
'label' => __( 'Popular Posts Section Title', 'rara-business' ),
'active_callback' => 'rara_business_page_post_section_ac'
)
);
$wp_customize->selective_refresh->add_partial( 'popular_post_title', array(
'selector' => '.popular-post h2.section-title',
'render_callback' => 'rara_business_popular_post_section_title_selective_refresh',
) );
/** Show Featured Image */
$wp_customize->add_setting(
'ed_featured_image',
array(
'default' => $default_options['ed_featured_image'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_featured_image',
array(
'section' => 'post_page_settings',
'label' => __( 'Show Featured Image', 'rara-business' ),
'description' => __( 'Enable to show featured image in post detail (single page).', 'rara-business' ),
)
)
);
/** Posts(Blog) & Pages Settings Ends */
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_post_page_section' );
if ( ! function_exists( 'rara_business_page_post_section_ac' ) ) :
/**
* Active Callback
*/
function rara_business_page_post_section_ac( $control ) {
$ed_related_post = $control->manager->get_setting( 'ed_related' )->value();
$ed_popular_post = $control->manager->get_setting( 'ed_popular_posts' )->value();
$control_id = $control->id;
if ( $control_id == 'related_post_title' && $ed_related_post ) return true;
if ( $control_id == 'popular_post_title' && $ed_popular_post ) return true;
}
endif;

View File

@@ -0,0 +1,102 @@
<?php
/**
* SEO Section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_seo_section' ) ) :
/**
* Add seo section controls
*/
function rara_business_customize_register_seo_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** SEO Settings */
$wp_customize->add_section(
'seo_settings',
array(
'title' => __( 'SEO Settings', 'rara-business' ),
'priority' => 30,
'panel' => 'general_settings_panel',
)
);
/** Enable updated date */
$wp_customize->add_setting(
'ed_post_update_date',
array(
'default' => $default_options['ed_post_update_date'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_post_update_date',
array(
'section' => 'seo_settings',
'label' => __( 'Enable Last Update Post Date', 'rara-business' ),
'description' => __( 'Enable to show last updated post date on listing as well as in single post.', 'rara-business' ),
)
)
);
/** Enable Breadcrumb */
$wp_customize->add_setting(
'ed_breadcrumb',
array(
'default' => $default_options['ed_breadcrumb'],
'sanitize_callback' => 'rara_business_sanitize_checkbox'
)
);
$wp_customize->add_control(
new Rara_Business_Toggle_Control(
$wp_customize,
'ed_breadcrumb',
array(
'section' => 'seo_settings',
'label' => __( 'Enable Breadcrumb', 'rara-business' ),
'description' => __( 'Enable to show breadcrumb in inner pages.', 'rara-business' ),
)
)
);
/** Breadcrumb Home Text */
$wp_customize->add_setting(
'home_text',
array(
'default' => $default_options['home_text'],
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'home_text',
array(
'type' => 'text',
'section' => 'seo_settings',
'label' => __( 'Breadcrumb Home Text', 'rara-business' ),
'active_callback' => 'rara_business_breadcrumb_ac',
)
);
/** SEO Settings Ends */
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_seo_section' );
if ( ! function_exists( 'rara_business_breadcrumb_ac' ) ) :
/**
* Active Callback
*/
function rara_business_breadcrumb_ac( $control ) {
$breadcrumb_control = $control->manager->get_setting( 'ed_breadcrumb' )->value();
$control_id = $control->id;
if ( $control_id == 'home_text' && $breadcrumb_control ) return true;
}
endif;

View File

@@ -0,0 +1,42 @@
<?php
/**
* Rara Business Theme Sanitization Functions
*
* @link https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php
* @package Rara_Business
*/
function rara_business_sanitize_checkbox( $checked ){
// Boolean check.
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
function rara_business_sanitize_select( $value ){
if ( is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) {
$value[ $key ] = sanitize_text_field( $subvalue );
}
return $value;
}
return sanitize_text_field( $value );
}
function rara_business_sanitize_radio( $input, $setting ) {
// Ensure input is a slug.
$input = sanitize_key( $input );
// Get list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it; otherwise, return the default.
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
function rara_business_sanitize_number_absint( $number, $setting ) {
// Ensure $number is an absolute integer (whole number, zero or greater).
$number = absint( $number );
// If the input is an absolute integer, return it; otherwise, return the default
return ( $number ? $number : $setting->default );
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* Rara Business Demo Content
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customizer_demo_content' ) ) :
/**
* Add demo content info
*/
function rara_business_customizer_demo_content( $wp_customize ) {
$wp_customize->add_section( 'demo_content_section' , array(
'title' => __( 'Demo Content Import' , 'rara-business' ),
'priority' => 7,
));
$wp_customize->add_setting(
'demo_content_instruction',
array(
'sanitize_callback' => 'wp_kses_post'
)
);
/* translators: 1: string, 2: url, 3: string */
$demo_content_description = sprintf( '%1$s<a class="documentation" href="%2$s" target="_blank">%3$s</a>', esc_html__( 'Rara Business comes with demo content import feature. You can import the demo content with just one click. For step-by-step video tutorial, ', 'rara-business' ), esc_url( 'https://rarathemes.com/blog/import-demo-content-rara-themes/' ), esc_html__( 'Click here', 'rara-business' ) );
$wp_customize->add_control(
new Rara_Business_Note_Control(
$wp_customize,
'demo_content_instruction',
array(
'section' => 'demo_content_section',
'description' => $demo_content_description
)
)
);
$theme_demo_content_desc = '';
if( ! class_exists( 'RDDI_init' ) ) {
$theme_demo_content_desc .= '<span class="sticky_info_row"><label class="row-element">' . __( 'Plugin required', 'rara-business' ) . ': </label><a href="' . esc_url( 'https://wordpress.org/plugins/rara-one-click-demo-import/' ) . '" target="_blank">' . __( 'Rara One Click Demo Import', 'rara-business' ) . '</a></span><br />';
}
$theme_demo_content_desc .= '<span class="sticky_info_row download-link"><label class="row-element">' . __( 'Download Demo Content', 'rara-business' ) . ': </label><a href="' . esc_url( 'https://docs.rarathemes.com/docs/rara-business/theme-installation-activation/how-to-import-demo-content/' ) . '" target="_blank">' . __( 'Click here', 'rara-business' ) . '</a></span><br />';
$wp_customize->add_setting( 'theme_demo_content_info',array(
'default' => '',
'sanitize_callback' => 'wp_kses_post',
));
// Demo content
$wp_customize->add_control( new Rara_Business_Note_Control( $wp_customize ,'theme_demo_content_info',array(
'section' => 'demo_content_section',
'description' => $theme_demo_content_desc
)));
}
endif;
add_action( 'customize_register', 'rara_business_customizer_demo_content' );

View File

@@ -0,0 +1,44 @@
<?php
/**
* Footer Setting
*
* @package Rara_Business
*/
function rara_business_customize_register_footer( $wp_customize ) {
$wp_customize->add_section(
'rara_business_footer_settings',
array(
'title' => __( 'Footer Settings', 'rara-business' ),
'priority' => 199,
'capability' => 'edit_theme_options',
)
);
/** Footer Copyright */
$wp_customize->add_setting(
'footer_copyright',
array(
'default' => '',
'sanitize_callback' => 'wp_kses_post',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
'footer_copyright',
array(
'label' => __( 'Footer Copyright Text', 'rara-business' ),
'section' => 'rara_business_footer_settings',
'type' => 'textarea',
)
);
$wp_customize->selective_refresh->add_partial( 'footer_copyright', array(
'selector' => '.site-footer .footer-b span.copyright',
'render_callback' => 'rara_business_get_footer_copyright',
) );
}
add_action( 'customize_register', 'rara_business_customize_register_footer' );

View File

@@ -0,0 +1,141 @@
<?php
/**
* Rara Business Theme Info
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customizer_theme_info' ) ) :
/**
* Add theme info
*/
function rara_business_customizer_theme_info( $wp_customize ) {
$wp_customize->add_section( 'theme_info_section', array(
'title' => __( 'Demo & Documentation' , 'rara-business' ),
'priority' => 6,
) );
/** Important Links */
$wp_customize->add_setting( 'theme_info_setting',
array(
'default' => '',
'sanitize_callback' => 'wp_kses_post',
)
);
$theme_info = '<p>';
/* translators: 1: string, 2: preview url, 3: string */
$theme_info .= sprintf( '%1$s<a href="%2$s" target="_blank">%3$s</a>', esc_html__( 'Demo Link : ', 'rara-business' ), esc_url( 'https://rarathemesdemo.com/' . RARA_BUSINESS_THEME_TEXTDOMAIN . '/'), esc_html__( 'Click here.', 'rara-business' ) );
$theme_info .= '</p><p>';
/* translators: 1: string, 2: documentation url, 3: string */
$theme_info .= sprintf( '%1$s<a href="%2$s" target="_blank">%3$s</a>', esc_html__( 'Documentation Link : ', 'rara-business' ), esc_url( 'https://docs.rarathemes.com/docs/rara-business/' ), esc_html__( 'Click here.', 'rara-business' ) );
$theme_info .= '</p>';
$wp_customize->add_control( new Rara_Business_Note_Control( $wp_customize,
'theme_info_setting',
array(
'section' => 'theme_info_section',
'description' => $theme_info
)
)
);
}
endif;
add_action( 'customize_register', 'rara_business_customizer_theme_info' );
if( class_exists( 'WP_Customize_Section' ) ) :
/**
* Adding Go to Pro Section in Customizer
* https://github.com/justintadlock/trt-customizer-pro
*/
class Rara_Business_Customize_Section_Pro extends WP_Customize_Section {
/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'pro-section';
/**
* Custom button text to output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $pro_text = '';
/**
* Custom pro button URL.
*
* @since 1.0.0
* @access public
* @var string
*/
public $pro_url = '';
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
* @access public
* @return void
*/
public function json() {
$json = parent::json();
$json['pro_text'] = $this->pro_text;
$json['pro_url'] = esc_url( $this->pro_url );
return $json;
}
/**
* Outputs the Underscore.js template.
*
* @since 1.0.0
* @access public
* @return void
*/
protected function render_template() { ?>
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
{{ data.title }}
<# if ( data.pro_text && data.pro_url ) { #>
<a href="{{ data.pro_url }}" class="button button-secondary alignright" target="_blank">{{ data.pro_text }}</a>
<# } #>
</h3>
</li>
<?php }
}
endif;
add_action( 'customize_register', 'rara_business_page_sections_pro' );
function rara_business_page_sections_pro( $manager ) {
// Register custom section types.
$manager->register_section_type( 'Rara_Business_Customize_Section_Pro' );
// Register sections.
$manager->add_section(
new Rara_Business_Customize_Section_Pro(
$manager,
'rara_business_view_pro',
array(
'title' => esc_html__( 'Pro Available', 'rara-business' ),
'priority' => 5,
'pro_text' => esc_html__( 'VIEW PRO THEME', 'rara-business' ),
'pro_url' => 'https://rarathemes.com/wordpress-themes/rara-business-pro/'
)
)
);
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Site Identitiy Customizer section
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_customize_register_site_identity_section' ) ) :
/**
* Add custom site identity controls
*/
function rara_business_customize_register_site_identity_section( $wp_customize ) {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
/** Add postMessage support for site title and description */
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
// Selective refresh for blogname
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'rara_business_customize_partial_blogname',
) );
// Selective refresh for blogdescription
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'rara_business_customize_partial_blogdescription',
) );
}
endif;
add_action( 'customize_register', 'rara_business_customize_register_site_identity_section' );

View File

@@ -0,0 +1,329 @@
<?php
/**
* Rara Business Customizer selective refresh functions.
*
* @package Rara_Business
*
*/
if ( ! function_exists( 'rara_business_customize_partial_blogname' ) ) :
/**
* Render the site title for the selective refresh partial.
*
*/
function rara_business_customize_partial_blogname() {
$blog_name = get_bloginfo( 'name' );
if ( $blog_name ){
return esc_html( $blog_name );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_customize_partial_blogdescription' ) ) :
/**
* Render the site description for the selective refresh partial.
*
*/
function rara_business_customize_partial_blogdescription() {
$blog_description = get_bloginfo( 'description' );
if ( $blog_description ){
return esc_html( $blog_description );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_banner_title_selective_refresh' ) ) :
/**
* Render banner title selective refresh partial.
*
*/
function rara_business_banner_title_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$banner_title = get_theme_mod( 'banner_title', $default_options['banner_title'] );
if ( $banner_title ){
return esc_html( $banner_title );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_banner_description_selective_refresh' ) ) :
/**
* Render banner description selective refresh partial.
*
*/
function rara_business_banner_description_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$banner_description = get_theme_mod( 'banner_description', $default_options['banner_description'] );
if ( $banner_description ){
return esc_html( $banner_description );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_banner_link_one_label_selective_refresh' ) ) :
/**
* Render banner link one label selective refresh partial.
*
*/
function rara_business_banner_link_one_label_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$banner_link_one_label = get_theme_mod( 'banner_link_one_label', $default_options['banner_link_one_label'] );
if ( $banner_link_one_label ){
return esc_html( $banner_link_one_label );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_banner_link_two_label_selective_refresh' ) ) :
/**
* Render banner link two label selective refresh partial.
*
*/
function rara_business_banner_link_two_label_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$banner_link_two_label = get_theme_mod( 'banner_link_two_label', $default_options['banner_link_two_label'] );
if ( $banner_link_two_label ){
return esc_html( $banner_link_two_label );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_portfolio_title_selective_refresh' ) ) :
/**
* Render portfolio title selective refresh partial.
*
*/
function rara_business_portfolio_title_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$portfolio_title = get_theme_mod( 'portfolio_title', $default_options['portfolio_title'] );
if ( $portfolio_title ){
return esc_html( $portfolio_title );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_portfolio_description_selective_refresh' ) ) :
/**
* Render portfolio description selective refresh partial.
*
*/
function rara_business_portfolio_description_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$portfolio_description = get_theme_mod( 'portfolio_description', $default_options['portfolio_description'] );
if ( $portfolio_description ){
return esc_html( $portfolio_description );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_blog_title_selective_refresh' ) ) :
/**
* Render blog title selective refresh partial.
*
*/
function rara_business_blog_title_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$blog_title = get_theme_mod( 'blog_title', $default_options['blog_title'] );
if ( $blog_title ){
return esc_html( $blog_title );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_blog_description_selective_refresh' ) ) :
/**
* Render blog description selective refresh partial.
*
*/
function rara_business_blog_description_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$blog_description = get_theme_mod( 'blog_description', $default_options['blog_description'] );
if ( $blog_description ){
return esc_html( $blog_description );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_header_phone_selective_refresh' ) ) :
/**
* Render header phone number selective refresh partial.
*
*/
function rara_business_header_phone_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$phone_number = get_theme_mod( 'header_phone', $default_options['header_phone'] );
if ( $phone_number ){
return esc_html( $phone_number );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_header_address_selective_refresh' ) ) :
/**
* Render header address number selective refresh partial.
*
*/
function rara_business_header_address_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$address = get_theme_mod( 'header_address', $default_options['header_address'] );
if ( $address ){
return esc_html( $address );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_header_email_selective_refresh' ) ) :
/**
* Render header email number selective refresh partial.
*
*/
function rara_business_header_email_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$email = get_theme_mod( 'header_email', $default_options['header_email'] );
if ( $email ){
return esc_html( $email );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_header_custom_link_label_selective_refresh' ) ) :
/**
* Render custom link label selective refresh partial.
*
*/
function rara_business_header_custom_link_label_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$custom_link_label = get_theme_mod( 'custom_link_label', $default_options['custom_link_label'] );
if ( $custom_link_label ){
return esc_html( $custom_link_label );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_readmore_label_selective_refresh' ) ) :
/**
* Render readmore label selective refresh partial.
*
*/
function rara_business_readmore_label_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$readmore_label = get_theme_mod( 'read_more_text', $default_options['read_more_text'] );
if ( $readmore_label ){
return esc_html( $readmore_label );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_related_post_section_title_selective_refresh' ) ) :
/**
* Render related post section title for selective refresh partial.
*
*/
function rara_business_related_post_section_title_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$related_post_title = get_theme_mod( 'related_post_title', $default_options['related_post_title'] );
if ( $related_post_title ){
return esc_html( $related_post_title );
} else {
return false;
}
}
endif;
if ( ! function_exists( 'rara_business_popular_post_section_title_selective_refresh' ) ) :
/**
* Render popular post section title for selective refresh partial.
*
*/
function rara_business_popular_post_section_title_selective_refresh() {
/** Load default theme options */
$default_options = rara_business_default_theme_options();
$popular_post_title = get_theme_mod( 'popular_post_title', $default_options['popular_post_title'] );
if ( $popular_post_title ){
return esc_html( $popular_post_title );
} else {
return false;
}
}
endif;
if( ! function_exists( 'rara_business_get_footer_copyright' ) ) :
/**
* Footer Copyright
*/
function rara_business_get_footer_copyright(){
$copyright = get_theme_mod( 'footer_copyright' );
echo '<span class="copyright">';
if( $copyright ){
echo wp_kses_post( $copyright );
}else{
esc_html_e( 'Copyright &copy; ', 'rara-business' );
echo date_i18n( esc_html__( 'Y', 'rara-business' ) );
echo ' <a href="' . esc_url( home_url( '/' ) ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a>. ';
}
echo '</span>';
}
endif;

View File

@@ -0,0 +1,202 @@
<?php
/**
* New React Dashboard page
*
* @package Rara_Business
*/
/**
* Init Admin Menu.
*
* @return void
*/
function rara_business_dashboard_menu() {
add_theme_page(
RARA_BUSINESS_THEME_NAME,
RARA_BUSINESS_THEME_NAME,
'manage_options',
'rara-business-dashboard',
'rara_business_dashboard_page'
);
}
add_action( 'admin_menu', 'rara_business_dashboard_menu' );
/**
* Callback function for React Dashboard Admin Page.
*
* @return void
*/
function rara_business_dashboard_page() { ?>
<div id="cw-dashboard" class="cw-dashboard"></div>
<?php
}
/**
* Enqueue scripts and styles for admin scripts.
*
* @return void
*/
function rara_business_dashboard_scripts() {
$admin_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : null;
if( $admin_page === 'rara-business-dashboard' ){
$dependencies_file_path = get_template_directory() . '/build/dashboard.asset.php';
if ( file_exists( $dependencies_file_path ) ) {
$dashboard_assets = require $dependencies_file_path;
$js_dependencies = ( ! empty( $dashboard_assets['dependencies'] ) ) ? $dashboard_assets['dependencies'] : [];
$version = ( ! empty( $dashboard_assets['version'] ) ) ? $dashboard_assets['version'] : '2.0.0';
$js_dependencies[] = 'updates';
wp_enqueue_script(
'rara-business-react-dashboard',
get_template_directory_uri() . '/build/dashboard.js',
$js_dependencies,
$version,
true
);
// Add Translation support for Dashboard
wp_set_script_translations( 'rara-business-react-dashboard', 'rara-business' );
$arrayargs = [
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'blog_name' => RARA_BUSINESS_THEME_NAME,
'theme_version' => RARA_BUSINESS_THEME_VERSION,
'inactivePlugins' => rara_business_get_inactive_plugins(),
'activePlugins' => rara_business_get_active_plugins(),
'review' => esc_url('https://wordpress.org/support/theme/rara-business/reviews/'),
'docmentation' => esc_url('https://docs.rarathemes.com/docs/rara-business/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=docs'),
'support' => esc_url('https://rarathemes.com/support-ticket/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=support'),
'videotutorial' => esc_url('https://www.youtube.com/@rarathemes'),
'get_pro' => esc_url('https://rarathemes.com/wordpress-themes/rara-business-pro/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=upgrade_to_pro'),
'website' => esc_url('https://rarathemes.com/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=website_visit'),
'theme_club_upgrade' => esc_url('https://rarathemes.com/theme-club/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=theme_club'),
'sales_funnel' => esc_url('https://rarathemes.com/sales-funnel/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=sales_funnel'),
'custom_fonts' => esc_url('https://rarathemes.com/wordpress-themes/wp-custom-fonts/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=wp_custom_fonts'),
'vip_site_care' => esc_url('https://rarathemes.com/vip-sitecare/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=vip_sitecare'),
'theme_install' => esc_url('https://rarathemes.com/wordpress-themes/theme-installation-and-setup/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=theme_install'),
'plugin_setup' => esc_url('https://rarathemes.com/wordpress-themes/must-have-plugins/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=plugin_setup'),
'seo_setup' => esc_url('https://rarathemes.com/wordpress-themes/must-have-seo-setup/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=seo_setup'),
'gdpr_setup' => esc_url('https://rarathemes.com/wordpress-themes/gdpr-compliance/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=gdpr_setup'),
'vip_support' => esc_url('https://rarathemes.com/wordpress-themes/vip-support/?utm_source=rara_business&utm_medium=dashboard&utm_campaign=vip_support'),
'customizer_url' => esc_url( admin_url( 'customize.php' ) ),
'custom_logo' => esc_url( admin_url( 'customize.php?autofocus[control]=custom_logo' ) ),
'colors' => esc_url( admin_url( 'customize.php?autofocus[section]=colors' ) ),
'typography' => esc_url(admin_url('customize.php?autofocus[section]=typography_settings')),
'general' => esc_url( admin_url( 'customize.php?autofocus[panel]=general_settings_panel' ) ),
'frontpage' => esc_url( admin_url( 'customize.php?autofocus[panel]=frontpage_panel' ) ),
'footer' => esc_url( admin_url( 'customize.php?autofocus[section]=rara_business_footer_settings' ) ),
];
wp_localize_script( 'rara-business-react-dashboard','cw_dashboard',$arrayargs );
}
wp_enqueue_style( 'rara-business-react-dashboard', get_template_directory_uri() . '/build/dashboard.css' );
}
}
add_action( 'admin_enqueue_scripts', 'rara_business_dashboard_scripts' );
/**
* Get the inactive plugins.
*
* @return array
*/
function rara_business_get_inactive_plugins() {
if (!current_user_can('install_plugins') && !current_user_can('activate_plugins')) {
return new \WP_Error( 'rest_forbidden', esc_html__( 'Sorry, you are not allowed to do that.', 'rara-business' ), array( 'status' => 403 ) );
}
// Get the list of all installed plugins
$all_plugins = get_plugins();
// Fetch the row from the options table containing active plugins
$active_plugins_option = get_option('active_plugins');
// Unserialize the active plugins data
$active_plugins = is_array($active_plugins_option) ? $active_plugins_option : [];
// Get the slugs of active plugins
$active_plugin_slugs = array_map(function($plugin) {
return plugin_basename($plugin);
}, $active_plugins);
// Get the slugs of inactive plugins
$inactive_plugin_slugs = array_diff(array_keys($all_plugins), $active_plugin_slugs);
// Get the details of inactive plugins
$inactive_plugins = array_intersect_key($all_plugins, array_flip($inactive_plugin_slugs));
// Initialize an empty array to hold the modified inactive plugins
$modified_inactive_plugins = array();
// Iterate over each inactive plugin
foreach ($inactive_plugins as $key => $plugin_data) {
$extract = explode( '/', $key );
// Extract the necessary information
$name = $plugin_data['Name'];
$slug = $extract[0];
// Add the plugin to the modified array
$modified_inactive_plugins[] = array(
'name' => esc_html($name),
'slug' => sanitize_title($slug),
'url' => rara_business_get_activation_url($slug)
);
}
// Return the modified array
return $modified_inactive_plugins;
}
/**
* Get the activation URL for a plugin.
*
* @param string $plugin_slug The plugin slug.
*
* @return string|bool The activation URL if the plugin exists, false otherwise.
*/
function rara_business_get_activation_url($plugin_slug) {
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
$plugins = get_plugins( '/' . $plugin_slug );
if ( ! empty( $plugins ) ) {
$keys = array_keys( $plugins );
$plugin_file = $plugin_slug . '/' . $keys[0];
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'activate',
'plugin' => $plugin_file,
),
admin_url( 'plugins.php' )
),
'activate-plugin_' . $plugin_file
);
return $url;
}
}
return false;
}
/**
* Get the active plugins.
*
* @return array
*/
function rara_business_get_active_plugins() {
$active_plugins = get_plugins();
$plugins = array();
foreach ($active_plugins as $key => $plugin) {
if ( is_plugin_active( $key ) ) {
$extract = explode( '/', $key );
$path = ABSPATH . 'wp-content/plugins/' . $key;
$plugin_data = get_plugin_data($path);
$plugins[] = array(
'name' => esc_html($plugin_data['Name']),
'slug' => sanitize_title($extract[0]),
'version' => esc_html($plugin_data['Version']),
);
}
}
return $plugins;
}

View File

@@ -0,0 +1,789 @@
<?php
/**
* Custom template tags for this theme
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package Rara_Business
*/
if ( ! function_exists( 'rara_business_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time.
*/
function rara_business_posted_on() {
$default_options = rara_business_default_theme_options(); // Get default theme options
$post_updated_date = get_theme_mod( 'ed_post_update_date', $default_options['ed_post_update_date'] );
$hide_date = get_theme_mod( 'ed_post_date_meta', $default_options['ed_post_date_meta'] );
$hide_author = get_theme_mod( 'ed_post_author_meta', $default_options['ed_post_author_meta'] );
$on = '';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
if( $post_updated_date ){
$time_string = '<time class="entry-date published updated" datetime="%3$s" itemprop="dateModified">%4$s</time></time><time class="updated" datetime="%1$s" itemprop="datePublished">%2$s</time>';
$on = __( 'Updated on ', 'rara-business' );
}else{
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time><time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
}
}else{
$time_string = '<time class="entry-date published updated" datetime="%1$s" itemprop="datePublished">%2$s</time><time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
if ( ! $hide_author && ! $hide_date ) {
$separator = '<span class="separator">/</span>';
} else {
$separator = '';
}
$posted_on = sprintf( '%1$s %2$s', esc_html( $on ), '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
echo '<span class="posted-on">'. $posted_on .'</span>'. $separator; // WPCS: XSS OK.
}
endif;
if( ! function_exists( 'rara_business_posted_by' ) ) :
/**
* Prints HTML with meta information for the current author
*/
function rara_business_posted_by(){
$default_options = rara_business_default_theme_options(); // Get default theme options
$hide_date = get_theme_mod( 'ed_post_date_meta', $default_options['ed_post_date_meta'] );
$hide_author = get_theme_mod( 'ed_post_author_meta', $default_options['ed_post_author_meta'] );
$byline = '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" itemprop="url"><span itemprop="name">' . esc_html( get_the_author() ) . '</span></a></span>';
echo '<span class="byline" itemprop="author" itemscope itemtype="https://schema.org/Person"> ' . $byline . '</span>';
}
endif;
if( ! function_exists( 'rara_business_categories' ) ) :
/**
* Categories
*/
function rara_business_categories(){
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
$categories_list = get_the_category_list( ' ' );
if ( $categories_list ) {
echo '<div class="categories">' . $categories_list . '</div>';
}
}
}
endif;
if( ! function_exists( 'rara_business_tags' ) ) :
/**
* Tags
*/
function rara_business_tags(){
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
$tags_list = get_the_tag_list( '', ' ' );
if ( $tags_list ) {
echo '<div class="tag">' . $tags_list . '</span>';
}
}
}
endif;
if( ! function_exists( 'rara_business_theme_comment' ) ) :
/**
* Callback function for Comment List *
*
* @link https://codex.wordpress.org/Function_Reference/wp_list_comments
*/
function rara_business_theme_comment( $comment, $args, $depth ){
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body" itemscope itemtype="https://schema.org/UserComments">
<?php endif; ?>
<footer class="comment-meta">
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
</div><!-- .comment-author vcard -->
</footer>
<div class="text-holder">
<div class="top">
<div class="left">
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'rara-business' ); ?></em>
<br />
<?php endif;
/* translators: %s: author link */
printf( __( '<b class="fn" itemprop="creator" itemscope itemtype="https://schema.org/Person">%s</b> <span class="says">says:</span>', 'rara-business' ), get_comment_author_link() );
?>
<div class="comment-metadata commentmetadata">
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<time itemprop="commentTime" datetime="<?php echo esc_attr( get_gmt_from_date( get_comment_date() . get_comment_time(), 'Y-m-d H:i:s' ) ); ?>">
<?php
/* translators: 1: comment date, 2: comment time */
printf( esc_html__( '%1$s at %2$s', 'rara-business' ), get_comment_date(), get_comment_time() ); ?>
</time>
</a>
</div>
</div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
</div>
<div class="comment-content" itemprop="commentText"><?php comment_text(); ?></div>
</div><!-- .text-holder -->
<?php if ( 'div' != $args['style'] ) : ?>
</div><!-- .comment-body -->
<?php endif; ?>
<?php
}
endif;
if( ! function_exists( 'rara_business_social_links' ) ) :
/**
* Prints social links in header
*/
function rara_business_social_links( $ed_social = false , $social_links = array() ){
if( $ed_social && $social_links ){
echo '<ul class="social-networks">';
foreach( $social_links as $link ){
if( $link['link'] && $link['font'] ) echo '<li><a href="' . esc_url( $link['link'] ) . '" target="_blank" rel="nofollow"><i class="' . esc_attr( $link['font'] ) . '"></i></a></li>';
}
echo '</ul>';
}
}
endif;
if( ! function_exists( 'rara_business_site_branding' ) ) :
/**
* Site Branding
*/
function rara_business_site_branding(){
$display_header_text = get_theme_mod( 'header_text', 1 );
$site_title = get_bloginfo( 'name', 'display' );
$description = get_bloginfo( 'description', 'display' );
if( ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) && $display_header_text && ( ! empty( $site_title ) || ! empty( $description ) ) ){
$branding_class = 'logo-with-site-identity';
} else {
$branding_class = '';
} ?>
<div class="site-branding <?php echo esc_attr( $branding_class ); ?>" itemscope itemtype="https://schema.org/Organization">
<?php
if( function_exists( 'has_custom_logo' ) && has_custom_logo() ) the_custom_logo();
echo '<div class="text-logo">';
if( is_front_page() ){ ?>
<h1 class="site-title" itemprop="name"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" itemprop="url"><?php bloginfo( 'name' ); ?></a></h1>
<?php } else { ?>
<p class="site-title" itemprop="name"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" itemprop="url"><?php bloginfo( 'name' ); ?></a></p>
<?php }
if ( $description || is_customize_preview() ){ ?>
<p class="site-description" itemprop="description"><?php echo esc_html( $description ); ?></p>
<?php }
echo '</div><!-- .text-logo -->';
?>
</div>
<?php
}
endif;
if( ! function_exists( 'rara_business_header_navigation' ) ) :
/**
* Navigation
*/
function rara_business_header_navigation(){
?>
<nav id="site-navigation" class="main-navigation" itemscope itemtype="https://schema.org/SiteNavigationElement">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'primary-menu',
'fallback_cb' => 'rara_business_primary_menu_fallback',
) );
?>
</nav><!-- #site-navigation -->
<?php
}
endif;
if( ! function_exists( 'rara_business_mobile_header' ) ) :
/**
* Mobile header
*/
function rara_business_mobile_header(){
$default_options = rara_business_default_theme_options();
$phone = get_theme_mod( 'header_phone', $default_options['header_phone'] );
$address = get_theme_mod( 'header_address', $default_options['header_address'] );
$email = get_theme_mod( 'header_email', $default_options['header_email'] );
$icon = get_theme_mod( 'custom_link_icon', $default_options['custom_link_icon'] );
$label = get_theme_mod( 'custom_link_label', $default_options['custom_link_label'] );
$ed_header_social = get_theme_mod( 'ed_header_social_links', $default_options['ed_header_social_links'] );
$social_links = get_theme_mod( 'header_social_links', $default_options['header_social_links'] );
$link = get_theme_mod( 'custom_link', $default_options['custom_link'] );
?>
<div class="responsive-menu-holder">
<div class="container">
<nav id="mobile-site-navigation" class="main-navigation mobile-navigation">
<div class="primary-menu-list main-menu-modal cover-modal" data-modal-target-string=".main-menu-modal">
<button class="close close-main-nav-toggle" data-toggle-target=".main-menu-modal" data-toggle-body-class="showing-main-menu-modal" aria-expanded="false" data-set-focus=".main-menu-modal"><i class="fas fa-times"></i></button>
<div class= "social-networks-holder">
<div class="container">
<?php rara_business_social_links( $ed_header_social, $social_links ); ?>
</div>
</div>
<div class="mobile-menu" aria-label="<?php esc_attr_e( 'Mobile', 'rara-business' ); ?>">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'mobile-primary-menu',
'menu_class' => 'nav-menu main-menu-modal',
'container' => false,
'fallback_cb' => 'rara_business_primary_menu_fallback',
) );
if( $link && $label ) rara_business_custom_link( $icon, $link, $label );
if( $phone || $address || $email ){ ?>
<div class="contact-info">
<?php
if( $phone ) rara_business_header_phone( $phone );
if( $address ) rara_business_header_address( $address );
if( $email ) rara_business_header_email( $email );
?>
</div>
<?php
}
?>
</div>
</div>
</nav><!-- #mobile-site-navigation -->
</div>
</div>
<?php
}
endif;
if( ! function_exists( 'rara_business_header_phone' ) ) :
/**
* Phone
*/
function rara_business_header_phone( $phone ){ ?>
<div class="phone">
<i class="fa fa-mobile-phone"></i>
<a href="<?php echo esc_url( 'tel:' . preg_replace( '/[^\d+]/', '', $phone ) ); ?>" class="tel-link"><?php echo esc_html( $phone ); ?></a>
</div>
<?php
}
endif;
if( ! function_exists( 'rara_business_header_address' ) ) :
/**
* Address
*/
function rara_business_header_address( $address ){ ?>
<div class="address" itemscope itemtype="https://schema.org/PostalAddress">
<i class="fa fa-map-marker"></i>
<address><?php echo esc_html( $address ); ?></address>
</div>
<?php
}
endif;
if( ! function_exists( 'rara_business_header_email' ) ) :
/**
* Email
*/
function rara_business_header_email( $email ){ ?>
<div class="email">
<i class="fa fa-envelope-o"></i>
<a href="<?php echo esc_url( 'mailto:' . sanitize_email( $email ) ); ?>" class="email-link"><?php echo esc_html( $email ); ?></a>
</div>
<?php
}
endif;
if( ! function_exists( 'rara_business_custom_link' ) ) :
/**
* Additional Link in menu
*/
function rara_business_custom_link( $icon, $link, $label ){
if( ! empty( $icon ) ){
echo '<a href="' . esc_url( $link ) . '" class="btn-buy custom_label"><i class="'. esc_attr( $icon ) .'"></i>' . esc_html( $label ) . '</a>';
} else {
echo '<a href="' . esc_url( $link ) . '" class="btn-buy">' . esc_html( $label ) . '</a>';
}
}
endif;
if( ! function_exists( 'rara_business_primary_menu_fallback' ) ) :
/**
* Primary Menu Fallback
*/
function rara_business_primary_menu_fallback(){
if( current_user_can( 'manage_options' ) ){
echo '<ul id="primary-menu" class="menu">';
echo '<li><a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '">' . esc_html__( 'Click here to add a menu', 'rara-business' ) . '</a></li>';
echo '</ul>';
}
}
endif;
if( ! function_exists( 'rara_business_get_home_sections' ) ) :
/**
* Returns Home Sections
*/
function rara_business_get_home_sections(){
$sections = array(
'services' => array( 'sidebar' => 'services' ),
'about' => array( 'sidebar' => 'about' ),
'choose-us' => array( 'sidebar' => 'choose-us' ),
'team' => array( 'sidebar' => 'team' ),
'testimonial' => array( 'sidebar' => 'testimonial' ),
'stats' => array( 'sidebar' => 'stats' ),
'portfolio' => array( 'section' => 'portfolio' ),
'blog' => array( 'section' => 'blog' ),
'cta' => array( 'sidebar' => 'cta' ),
'faq' => array( 'sidebar' => 'faq' ),
'client' => array( 'sidebar' => 'client' )
);
$enabled_section = array();
foreach( $sections as $k => $v ){
if( array_key_exists( 'sidebar', $v ) ){
if( is_active_sidebar( $v['sidebar'] ) ) array_push( $enabled_section, $v['sidebar'] );
}else{
if( get_theme_mod( 'ed_' . $v['section'] . '_section', true ) ) array_push( $enabled_section, $v['section'] );
}
}
return apply_filters( 'rara_business_home_sections', $enabled_section );
}
endif;
if( ! function_exists( 'rara_business_get_portfolio_buttons' ) ) :
/**
* Query for Portfolio Buttons
*/
function rara_business_get_portfolio_buttons( $no_of_portfolio, $home = false ){
if( taxonomy_exists( 'rara_portfolio_categories' ) ){
if( $home ){
$s = '';
$i = 0;
$portfolio_posts = get_posts( array( 'post_type' => 'rara-portfolio', 'post_status' => 'publish', 'posts_per_page' => $no_of_portfolio ) );
foreach( $portfolio_posts as $portfolio ){
$terms = get_the_terms( $portfolio->ID, 'rara_portfolio_categories' );
if( $terms ){
foreach( $terms as $term ){
$i++;
$s .= $term->term_id;
$s .= ', ';
}
}
}
$term_ids = explode( ', ', $s );
$term_ids = array_diff( array_unique( $term_ids ), array('') );
wp_reset_postdata();//Reseting get_posts
}
$args = array(
'taxonomy' => 'rara_portfolio_categories',
'orderby' => 'name',
'order' => 'ASC',
);
$terms = get_terms( $args );
if( $terms ){
?>
<div class="button-group filter-button-group">
<button data-filter="*" class="button is-checked"><?php echo esc_html_e( 'All', 'rara-business' ); ?></button><!-- This is HACK for reducing space between inline block elements.
--><?php
foreach( $terms as $t ){
if( $home ){
if( in_array( $t->term_id, $term_ids ) )
echo '<button class="button" data-filter=".' . esc_attr( $t->slug ) . '">' . esc_html( $t->name ) . '</button>';
}else{
echo '<button class="button" data-filter=".' . esc_attr( $t->slug ) . '">' . esc_html( $t->name ) . '</button>';
}
}
?>
</div>
<?php
}
}
}
endif;
if( ! function_exists( 'rara_business_get_portfolios' ) ) :
/**
* Query for portfolios
*/
function rara_business_get_portfolios( $no_of_portfolio = -1 ){
$portfolio_qry = new WP_Query( array( 'post_type' => 'rara-portfolio', 'post_status' => 'publish', 'posts_per_page' => $no_of_portfolio ) );
if( taxonomy_exists( 'rara_portfolio_categories' ) && $portfolio_qry->have_posts() ){ ?>
<div class="filter-grid">
<?php
while( $portfolio_qry->have_posts() ){
$portfolio_qry->the_post();
$terms = get_the_terms( get_the_ID(), 'rara_portfolio_categories' );
$s = '';
$n = '';
$i = 0;
if( $terms ){
foreach( $terms as $t ){
$i++;
$s .= $t->slug;
$n .= '#'.$t->name;
if( count( $terms ) > $i ){
$s .= ' ';
$n .= ' ';
}
}
}
if( has_post_thumbnail() ){ ?>
<div class="element-item <?php echo esc_attr( $s );?>">
<div class="img-holder">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'rara-business-portfolio' ); ?>
</a>
<div class="text-holder">
<div class="text">
<?php
the_title( '<h3 class="title">', '</h3>' );
if( $n ) echo '<p>'. esc_html( $n ) .'</p>';
?>
</div>
</div>
</div>
</div>
<?php }
}
?>
</div><!-- .filter-grid -->
<?php
wp_reset_postdata();
}
}
endif;
/**
* Query WooCommerce activation
*/
function rara_business_is_woocommerce_activated() {
return class_exists( 'woocommerce' ) ? true : false;
}
/**
* Query Rara theme companion activation
*/
function rara_business_is_rara_theme_companion_activated() {
return class_exists( 'Raratheme_Companion_Public' ) ? true : false;
}
if( ! function_exists( 'rara_business_get_svg' ) ) :
/**
* Return SVG markup.
*
* @param array $args {
* Parameters needed to display an SVG.
*
* @type string $icon Required SVG icon filename.
* @type string $title Optional SVG title.
* @type string $desc Optional SVG description.
* }
* @return string SVG markup.
*/
function rara_business_get_svg( $args = array() ) {
// Make sure $args are an array.
if ( empty( $args ) ) {
return __( 'Please define default parameters in the form of an array.', 'rara-business' );
}
// Define an icon.
if ( false === array_key_exists( 'icon', $args ) ) {
return __( 'Please define an SVG icon filename.', 'rara-business' );
}
// Set defaults.
$defaults = array(
'icon' => '',
'title' => '',
'desc' => '',
'fallback' => false,
);
// Parse args.
$args = wp_parse_args( $args, $defaults );
// Set aria hidden.
$aria_hidden = ' aria-hidden="true"';
// Set ARIA.
$aria_labelledby = '';
/*
* Restaurant and Cafe Pro doesn't use the SVG title or description attributes; non-decorative icons are described with .screen-reader-text.
*
* However, child themes can use the title and description to add information to non-decorative SVG icons to improve accessibility.
*
* Example 1 with title: <?php echo rara_business_get_svg( array( 'icon' => 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ) ) ); ?>
*
* Example 2 with title and description: <?php echo rara_business_get_svg( array( 'icon' => 'arrow-right', 'title' => __( 'This is the title', 'textdomain' ), 'desc' => __( 'This is the description', 'textdomain' ) ) ); ?>
*
* See https://www.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/.
*/
if ( $args['title'] ) {
$aria_hidden = '';
$unique_id = uniqid();
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"';
if ( $args['desc'] ) {
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"';
}
}
// Begin SVG markup.
$svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . $aria_labelledby . ' role="img">';
// Display the title.
if ( $args['title'] ) {
$svg .= '<title id="title-' . $unique_id . '">' . esc_html( $args['title'] ) . '</title>';
// Display the desc only if the title is already set.
if ( $args['desc'] ) {
$svg .= '<desc id="desc-' . $unique_id . '">' . esc_html( $args['desc'] ) . '</desc>';
}
}
/*
* Display the icon.
*
* The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
*
* See https://core.trac.wordpress.org/ticket/38387.
*/
$svg .= ' <use href="#icon-' . esc_attr( $args['icon'] ) . '" xlink:href="#icon-' . esc_attr( $args['icon'] ) . '"></use> ';
// Add some markup to use as a fallback for browsers that do not support SVGs.
if ( $args['fallback'] ) {
$svg .= '<span class="svg-fallback icon-' . esc_attr( $args['icon'] ) . '"></span>';
}
$svg .= '</svg>';
return $svg;
}
endif;
if( ! function_exists( 'rara_business_sidebar_layout' ) ) :
/**
* Return sidebar layouts for pages/posts
*/
function rara_business_sidebar_layout(){
global $post;
$return = false;
$page_layout = get_theme_mod( 'page_sidebar_layout', 'right-sidebar' ); //Default Layout Style for Pages
$post_layout = get_theme_mod( 'post_sidebar_layout', 'right-sidebar' ); //Default Layout Style for Posts
if( is_singular( array( 'page', 'post' ) ) ){
if( get_post_meta( $post->ID, 'sidebar_layout', true ) ){
$sidebar_layout = get_post_meta( $post->ID, 'sidebar_layout', true );
}else{
$sidebar_layout = 'default-sidebar';
}
if( is_page() ){
if( is_page_template( 'templates/portfolio.php' ) ){
$return = '';
}elseif( is_active_sidebar( 'sidebar' ) ){
if( $sidebar_layout == 'no-sidebar' ){
$return = 'full-width';
}elseif( ( $sidebar_layout == 'default-sidebar' && $page_layout == 'right-sidebar' ) || ( $sidebar_layout == 'right-sidebar' ) ){
$return = 'rightsidebar';
}elseif( ( $sidebar_layout == 'default-sidebar' && $page_layout == 'left-sidebar' ) || ( $sidebar_layout == 'left-sidebar' ) ){
$return = 'leftsidebar';
}elseif( $sidebar_layout == 'default-sidebar' && $page_layout == 'no-sidebar' ){
$return = 'full-width';
}
}else{
$return = 'full-width';
}
}elseif( is_single() ){
if( is_active_sidebar( 'sidebar' ) ){
if( $sidebar_layout == 'no-sidebar' ){
$return = 'full-width';
}elseif( ( $sidebar_layout == 'default-sidebar' && $post_layout == 'right-sidebar' ) || ( $sidebar_layout == 'right-sidebar' ) ){
$return = 'rightsidebar';
}elseif( ( $sidebar_layout == 'default-sidebar' && $post_layout == 'left-sidebar' ) || ( $sidebar_layout == 'left-sidebar' ) ){
$return = 'leftsidebar';
}elseif( $sidebar_layout == 'default-sidebar' && $post_layout == 'no-sidebar' ){
$return = 'full-width';
}
}else{
$return = 'full-width';
}
}
}elseif( is_tax( 'rara_portfolio_categories' ) ){
$return = 'page-template-portfolio';
}elseif( is_singular( 'rara-portfolio' ) ){
$return = 'full-width';
}elseif( rara_business_is_woocommerce_activated() && is_post_type_archive( 'product' ) ){
if( is_active_sidebar( 'shop-sidebar' ) ){
$return = 'rightsidebar';
}else{
$return = 'full-width';
}
}else{
if( is_active_sidebar( 'sidebar' ) ){
$return = 'rightsidebar';
}else{
$return = 'full-width';
}
}
return $return;
}
endif;
if( ! function_exists( 'rara_business_escape_text_tags' ) ) :
/**
* Remove new line tags from string
*
* @param $text
*
* @return string
*/
function rara_business_escape_text_tags( $text ) {
return (string) str_replace( array( "\r", "\n" ), '', strip_tags( $text ) );
}
endif;
if( ! function_exists( 'rara_business_fonts_url' ) ) :
/**
* Register custom fonts.
*/
function rara_business_fonts_url() {
$fonts_url = '';
/*
* Translators: If there are characters in your language that are not
* supported by Lato fonts, translate this to 'off'. Do not translate
* into your own language.
*/
$lato_font = _x( 'on', 'Lato font: on or off', 'rara-business' );
/*
* Translators: If there are characters in your language that are not
* supported by Montserrat fonts, translate this to 'off'. Do not translate
* into your own language.
*/
$montserrat_font = _x( 'on', 'Montserrat font: on or off', 'rara-business' );
if ( 'off' !== $lato_font || 'off' !== $montserrat_font ) {
$font_families = array();
if ( 'off' !== $lato_font ) {
$font_families[] = 'Lato:100,100i,300,300i,400,400i,700,700i,900,900i';
}
if ( 'off' !== $montserrat_font ) {
$font_families[] = 'Montserrat:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
'display' => urlencode( 'fallback' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return esc_url( $fonts_url );
}
endif;
if ( ! function_exists( 'wp_body_open' ) ) :
/**
* Fire the wp_body_open action.
*
* Added for backwards compatibility to support pre 5.2.0 WordPress versions.
*
*/
function wp_body_open() {
/**
* Triggered after the opening <body> tag.
*
*/
do_action( 'wp_body_open' );
}
endif;
if( ! function_exists( 'rara_business_load_preload_local_fonts') ) :
/**
* Get the file preloads.
*
* @param string $url The URL of the remote webfont.
* @param string $format The font-format. If you need to support IE, change this to "woff".
*/
function rara_business_load_preload_local_fonts( $url, $format = 'woff2' ) {
// Check if cached font files data preset present or not. Basically avoiding 'rara_business_WebFont_Loader' class rendering.
$local_font_files = get_site_option( 'rara_business_local_font_files', false );
if ( is_array( $local_font_files ) && ! empty( $local_font_files ) ) {
$font_format = apply_filters( 'rara_business_local_google_fonts_format', $format );
foreach ( $local_font_files as $key => $local_font ) {
if ( $local_font ) {
echo '<link rel="preload" href="' . esc_url( $local_font ) . '" as="font" type="font/' . esc_attr( $font_format ) . '" crossorigin>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
return;
}
// Now preload font data after processing it, as we didn't get stored data.
$font = rara_business_webfont_loader_instance( $url );
$font->set_font_format( $format );
$font->preload_local_fonts();
}
endif;
if( ! function_exists( 'rara_business_flush_local_google_fonts' ) ){
/**
* Ajax Callback for flushing the local font
*/
function rara_business_flush_local_google_fonts() {
$WebFontLoader = new Rara_Business_WebFont_Loader();
//deleting the fonts folder using ajax
$WebFontLoader->delete_fonts_folder();
die();
}
}
add_action( 'wp_ajax_flush_local_google_fonts', 'rara_business_flush_local_google_fonts' );
add_action( 'wp_ajax_nopriv_flush_local_google_fonts', 'rara_business_flush_local_google_fonts' );

View File

@@ -0,0 +1,18 @@
jQuery(document).ready(function($){
function check_page_templates(){
$('.inside #page_template').each(function(i,e){
if( $(this).val() === "templates/portfolio.php" ){
$('#rara_business_sidebar_layout').hide();
}else{
$('#rara_business_sidebar_layout').show();
}
});
}
$('.inside #page_template').on( 'change', check_page_templates );
// Hide metabox options when static front page is set
if( rb_show_metabox.hide_metabox == '1' ){
$('#rara_business_sidebar_layout').hide();
}
} )

View File

@@ -0,0 +1,128 @@
( function( api ) {
// Extends our custom "example-1" section.
api.sectionConstructor['pro-section'] = api.Section.extend( {
// No events for this type of section.
attachEvents: function () {},
// Always make the section active.
isContextuallyActive: function () {
return true;
}
} );
} )( wp.customize );
jQuery(document).ready(function($) {
/* Move widgets to their respective sections */
wp.customize.section( 'sidebar-widgets-services' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-services' ).priority( '50' );
wp.customize.section( 'sidebar-widgets-about' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-about' ).priority( '55' );
wp.customize.section( 'sidebar-widgets-choose-us' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-choose-us' ).priority( '60' );
wp.customize.section( 'sidebar-widgets-team' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-team' ).priority( '65' );
wp.customize.section( 'sidebar-widgets-testimonial' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-testimonial' ).priority( '70' );
wp.customize.section( 'sidebar-widgets-stats' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-stats' ).priority( '75' );
wp.customize.section( 'sidebar-widgets-cta' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-cta' ).priority( '80' );
wp.customize.section( 'sidebar-widgets-faq' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-faq' ).priority( '85' );
wp.customize.section( 'sidebar-widgets-client' ).panel( 'frontpage_panel' );
wp.customize.section( 'sidebar-widgets-client' ).priority( '90' );
// Scroll to section
$('body').on('click', '#sub-accordion-panel-frontpage_panel .control-subsection .accordion-section-title', function(event) {
var section_id = $(this).parent('.control-subsection').attr('id');
scrollToSection( section_id );
});
$('body').on('click', '.flush-it', function(event) {
$.ajax ({
url : rara_business_cdata.ajax_url,
type : 'post',
data : 'action=flush_local_google_fonts',
nonce : rara_business_cdata.nonce,
success : function(results){
//results can be appended in needed
$( '.flush-it' ).val(rara_business_cdata.flushit);
},
});
});
});
function scrollToSection( section_id ){
var preview_section_id = "banner_section";
var $contents = jQuery('#customize-preview iframe').contents();
switch ( section_id ) {
case 'accordion-section-header_image':
preview_section_id = "banner-section";
break;
case 'accordion-section-sidebar-widgets-services':
preview_section_id = "services-section";
break;
case 'accordion-section-sidebar-widgets-about':
preview_section_id = "about-section";
break;
case 'accordion-section-sidebar-widgets-choose-us':
preview_section_id = "choose-us";
break;
case 'accordion-section-sidebar-widgets-team':
preview_section_id = "team-section";
break;
case 'accordion-section-sidebar-widgets-testimonial':
preview_section_id = "testimonial-section";
break;
case 'accordion-section-sidebar-widgets-stats':
preview_section_id = "stats-section";
break;
case 'accordion-section-portfolio_section':
preview_section_id = "portfolio-section";
break;
case 'accordion-section-blog_section':
preview_section_id = "blog-section";
break;
case 'accordion-section-sidebar-widgets-cta':
preview_section_id = "cta-section";
break;
case 'accordion-section-sidebar-widgets-faq':
preview_section_id = "faq-section";
break;
case 'accordion-section-sidebar-widgets-client':
preview_section_id = "client-section";
break;
}
if( $contents.find('#'+preview_section_id).length > 0 && $contents.find('.home').length > 0 ){
$contents.find("html, body").animate({
scrollTop: $contents.find( "#" + preview_section_id ).offset().top
}, 1000);
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* Metabox for Sidebar Layout
*
* @package Rara_Business
*
*/
function rara_business_add_sidebar_layout_box(){
$screens = array( 'post', 'page' );
foreach( $screens as $screen ){
add_meta_box(
'rara_business_sidebar_layout',
__( 'Sidebar Layout', 'rara-business' ),
'rara_business_sidebar_layout_callback',
$screen,
'normal',
'high'
);
}
}
add_action( 'add_meta_boxes', 'rara_business_add_sidebar_layout_box' );
$rara_business_sidebar_layout = array(
'default-sidebar'=> array(
'value' => 'default-sidebar',
'label' => __( 'Default Sidebar', 'rara-business' ),
'thumbnail' => get_template_directory_uri() . '/images/default-sidebar.png'
),
'no-sidebar' => array(
'value' => 'no-sidebar',
'label' => __( 'Full Width', 'rara-business' ),
'thumbnail' => get_template_directory_uri() . '/images/no-sidebar.png'
),
'left-sidebar' => array(
'value' => 'left-sidebar',
'label' => __( 'Left Sidebar', 'rara-business' ),
'thumbnail' => get_template_directory_uri() . '/images/left-sidebar.png'
),
'right-sidebar' => array(
'value' => 'right-sidebar',
'label' => __( 'Right Sidebar', 'rara-business' ),
'thumbnail' => get_template_directory_uri() . '/images/right-sidebar.png'
)
);
function rara_business_sidebar_layout_callback(){
global $post, $rara_business_sidebar_layout;
wp_nonce_field( basename( __FILE__ ), 'rara_business_nonce' );
?>
<table class="form-table">
<tr>
<td colspan="4"><em class="f13"><?php esc_html_e( 'Choose Sidebar Template', 'rara-business' ); ?></em></td>
</tr>
<tr>
<td>
<?php
foreach( $rara_business_sidebar_layout as $field ){
$layout = get_post_meta( $post->ID, 'sidebar_layout', true ); ?>
<div class="radio-image-wrapper" style="float:left; margin-right:30px;">
<label class="description">
<span><img src="<?php echo esc_url( $field['thumbnail'] ); ?>" alt="<?php echo esc_attr( $field['label'] ); ?>" /></span><br/>
<input type="radio" name="sidebar_layout" value="<?php echo esc_attr( $field['value'] ); ?>" <?php checked( $field['value'], $layout ); if( empty( $layout ) ){ checked( $field['value'], 'default-sidebar' ); }?>/>&nbsp;<?php echo esc_html( $field['label'] ); ?>
</label>
</div>
<?php } // end foreach
?>
<div class="clear"></div>
</td>
</tr>
</table>
<?php
}
function rara_business_savesidebar_layout( $post_id ){
global $rara_business_sidebar_layout;
// Verify the nonce before proceeding.
if( !isset( $_POST[ 'rara_business_nonce' ] ) || !wp_verify_nonce( $_POST[ 'rara_business_nonce' ], basename( __FILE__ ) ) )
return;
// Stop WP from clearing custom fields on autosave
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if( 'page' == $_POST['post_type'] ){
if( ! current_user_can( 'edit_page', $post_id ) ) return $post_id;
}elseif( ! current_user_can( 'edit_post', $post_id ) ){
return $post_id;
}
$layout = isset( $_POST['sidebar_layout'] ) ? sanitize_key( $_POST['sidebar_layout'] ) : 'default-sidebar';
if( array_key_exists( $layout, $rara_business_sidebar_layout ) ){
update_post_meta( $post_id, 'sidebar_layout', $layout );
}else{
delete_post_meta( $post_id, 'sidebar_layout' );
}
}
add_action( 'save_post' , 'rara_business_savesidebar_layout' );

View File

@@ -0,0 +1,84 @@
<?php
/**
* Filter to modify functionality of RTC plugin.
*
* @package Rara_Business
*/
if( ! function_exists( 'rara_business_cta_section_bgcolor_filter' ) ){
/**
* Filter to add bg color of cta section widget
*/
function rara_business_cta_section_bgcolor_filter(){
return '#0aa3f3';
}
}
add_filter( 'rrtc_cta_bg_color', 'rara_business_cta_section_bgcolor_filter' );
if( ! function_exists( 'rara_business_cta_btn_alignment_filter' ) ){
/**
* Filter to add btn alignment of cta section widget
*/
function rara_business_cta_btn_alignment_filter(){
return 'centered';
}
}
add_filter( 'rrtc_cta_btn_alignment', 'rara_business_cta_btn_alignment_filter' );
if( ! function_exists( 'rara_business_team_member_image_size' ) ){
/**
* Filter to define image size in team member section widget
*/
function rara_business_team_member_image_size(){
return 'rara-business-team';
}
}
add_filter( 'tmw_icon_img_size', 'rara_business_team_member_image_size' );
if( ! function_exists( 'rara_business_modify_testimonial_widget' ) ){
/**
* Filter to add modify testimonial widget
*/
function rara_business_modify_testimonial_widget( $html, $args, $instance ){
$obj = new RaraTheme_Companion_Functions();
$name = ! empty( $instance['name'] ) ? $instance['name'] : '' ;
$designation = ! empty( $instance['designation'] ) ? $instance['designation'] : '' ;
$testimonial = ! empty( $instance['testimonial'] ) ? $instance['testimonial'] : '';
$image = ! empty( $instance['image'] ) ? $instance['image'] : '';
if( $image )
{
$attachment_id = $image;
$icon_img_size = apply_filters('icon_img_size','rttk-thumb');
}
ob_start();
?>
<div class="rtc-testimonial-holder">
<div class="rtc-testimonial-inner-holder">
<div class="text-holder">
<?php if( $image ){ ?>
<div class="img-holder">
<?php echo wp_get_attachment_image( $attachment_id, $icon_img_size, false,
array( 'alt' => esc_attr( $name ))) ;?>
</div>
<?php }?>
<div class="testimonial-meta">
<?php
if( $name ) { echo '<span class="name">'.$name.'</span>'; }
if( isset( $designation ) && $designation!='' ){
echo '<span class="designation">'.esc_attr($designation).'</span>';
}
?>
</div>
</div>
<?php if( $testimonial ) echo '<div class="testimonial-content">'.wpautop( wp_kses_post( $testimonial ) ).'</div>'; ?>
</div>
</div>
<?php
$html = ob_get_clean();
return $html;
}
}
add_filter( 'raratheme_companion_testimonial_widget_filter', 'rara_business_modify_testimonial_widget', 10, 3 );

View File

@@ -0,0 +1,90 @@
<?php
/**
* This file represents an example of the code that themes would use to register
* the required plugins.
*
* It is expected that theme authors would copy and paste this code into their
* functions.php file, and amend to suit.
*
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation.
*
* @package TGM-Plugin-Activation
* @subpackage Example
* @version 2.6.1 for parent theme Rara Business for publication on WordPress.org
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
* @copyright Copyright (c) 2011, Thomas Griffin
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
* @link https://github.com/TGMPA/TGM-Plugin-Activation
*/
/**
* Include the TGM_Plugin_Activation class.
*/
require_once get_template_directory() . '/inc/tgmpa/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'rara_business_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
* In this example, we register five plugins:
* - one included with the TGMPA library
* - two from an external source, one from an arbitrary source, one from a GitHub repository
* - two from the .org repo, where one demonstrates the use of the `is_callable` argument
*
* The variables passed to the `tgmpa()` function should be:
* - an array of plugin arrays;
* - optionally a configuration array.
* If you are not changing anything in the configuration array, you can remove the array and remove the
* variable from the function call: `tgmpa( $plugins );`.
* In that case, the TGMPA default settings will be used.
*
* This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10.
*/
function rara_business_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// This is an example of how to include a plugin from the WordPress Plugin Repository.
array(
'name' => __( 'RaraTheme Companion', 'rara-business' ),
'slug' => 'raratheme-companion',
'required' => false,
),
array(
'name' => __( 'Newsletter', 'rara-business' ),
'slug' => 'newsletter',
'required' => false,
),
array(
'name' => __( 'Rara One Click Demo Import','rara-business' ),
'slug' => 'rara-one-click-demo-import',
'required' => false,
),
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'rara-business', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
* @package Rara_Business
*/
function rara_business_widgets_init() {
$sidebars = array(
'sidebar' => array(
'name' => __( 'Sidebar', 'rara-business' ),
'id' => 'sidebar',
'description' => __( 'Default Sidebar', 'rara-business' ),
),
'services' => array(
'name' => __( 'Services Section', 'rara-business' ),
'id' => 'services',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: Icon Text" widget for the services.', 'rara-business' ),
),
'about' => array(
'name' => __( 'About Section', 'rara-business' ),
'id' => 'about',
'description' => __( 'Add "Rara: Featured Page Widget" for about section.', 'rara-business' ),
),
'choose-us' => array(
'name' => __( 'Why Choose Us Section', 'rara-business' ),
'id' => 'choose-us',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: Icon Text" widget for the choos us reasons. Add "Image" widget for featured image.', 'rara-business' ),
),
'team' => array(
'name' => __( 'Team Section', 'rara-business' ),
'id' => 'team',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: Team Member" widget for the team members.', 'rara-business' ),
),
'testimonial' => array(
'name' => __( 'Testimonial Section', 'rara-business' ),
'id' => 'testimonial',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: Testimonial" widget for the testimonials.', 'rara-business' ),
),
'stats' => array(
'name' => __( 'Stat Counter Section', 'rara-business' ),
'id' => 'stats',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: Stat Counter Widget" for the statistics.', 'rara-business' ),
),
'cta' => array(
'name' => __( 'Call To Action Section', 'rara-business' ),
'id' => 'cta',
'description' => __( 'Add "Rara : Call To Action widget" for the title, description and call to action buttons.', 'rara-business' ),
),
'faq' => array(
'name' => __( 'FAQs Section', 'rara-business' ),
'id' => 'faq',
'description' => __( 'Add "Text" widget for the title and description. Add "Rara: FAQs" widget for frequently asked questions.', 'rara-business' ),
),
'client' => array(
'name' => __( 'Clients Section', 'rara-business' ),
'id' => 'client',
'description' => __( 'Add "Rara: Client Logo" widget for client logos.', 'rara-business' ),
),
'footer-one'=> array(
'name' => __( 'Footer One', 'rara-business' ),
'id' => 'footer-one',
'description' => __( 'Add footer one widgets here.', 'rara-business' ),
),
'footer-two'=> array(
'name' => __( 'Footer Two', 'rara-business' ),
'id' => 'footer-two',
'description' => __( 'Add footer two widgets here.', 'rara-business' ),
),
'footer-three'=> array(
'name' => __( 'Footer Three', 'rara-business' ),
'id' => 'footer-three',
'description' => __( 'Add footer three widgets here.', 'rara-business' ),
),
'footer-four'=> array(
'name' => __( 'Footer Four', 'rara-business' ),
'id' => 'footer-four',
'description' => __( 'Add footer four widgets here.', 'rara-business' ),
)
);
foreach( $sidebars as $sidebar ){
register_sidebar( array(
'name' => esc_html( $sidebar['name'] ),
'id' => esc_attr( $sidebar['id'] ),
'description' => esc_html( $sidebar['description'] ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title" itemprop="name">',
'after_title' => '</h2>',
) );
}
}
add_action( 'widgets_init', 'rara_business_widgets_init' );
if( ! function_exists( 'rara_business_recent_post_thumbnail' ) ):
/**
* Filter to modify recent post widget thumbnail image
*/
function rara_business_recent_post_thumbnail( $size ){
return $size = "rara-business-blog";
}
endif;
add_filter( 'rara_recent_img_size', 'rara_business_recent_post_thumbnail' );

View File

@@ -0,0 +1,85 @@
<?php
/**
* woocommerce hooks and functions.
*
* @link https://docs.woothemes.com/document/third-party-custom-theme-compatibility/
*
* @package Rara_Business
*/
/**
* Woocommerce related hooks
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action( 'woocommerce_before_main_content', 'rara_business_wc_wrapper', 10 );
add_action( 'woocommerce_after_main_content', 'rara_business_wc_wrapper_end', 10 );
add_action( 'after_setup_theme', 'rara_business_wc_support' );
add_action( 'woocommerce_sidebar', 'rara_business_wc_sidebar_cb' );
add_action( 'widgets_init', 'rara_business_wc_widgets_init' );
add_filter( 'woocommerce_show_page_title' , '__return_false' );
/**
* Declare Woocommerce Support
*/
function rara_business_wc_support() {
global $woocommerce;
add_theme_support( 'woocommerce' );
if( version_compare( $woocommerce->version, '3.0', ">=" ) ) {
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
}
/**
* Woocommerce Sidebar
*/
function rara_business_wc_widgets_init(){
register_sidebar( array(
'name' => esc_html__( 'Shop Sidebar', 'rara-business' ),
'id' => 'shop-sidebar',
'description' => esc_html__( 'Sidebar displaying only in woocommerce pages.', 'rara-business' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
/**
* Before Content
* Wraps all WooCommerce content in wrappers which match the theme markup
*/
function rara_business_wc_wrapper(){
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
}
/**
* After Content
* Closes the wrapping divs
*/
function rara_business_wc_wrapper_end(){
?>
</main>
</div>
<?php
}
/**
* Callback function for Shop sidebar
*/
function rara_business_wc_sidebar_cb(){
if( is_active_sidebar( 'shop-sidebar' ) ){
echo '<div class="sidebar"><aside id="secondary" class="widget-area" role="complementary">';
dynamic_sidebar( 'shop-sidebar' );
echo '</aside></div>';
}
}