khaihihi
This commit is contained in:
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Social Profiles
|
||||
* @subpackage Wordpress
|
||||
* @author Kevin Provance (kprovance)
|
||||
* @version 1.0.8
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if( !defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
// Don't duplicate me!
|
||||
if( !class_exists( 'ReduxFramework_extension_social_profiles' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Main ReduxFramework social profiles extension class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_extension_social_profiles {
|
||||
|
||||
public static $version = '1.0.8';
|
||||
|
||||
// Protected vars
|
||||
protected $parent;
|
||||
public $extension_url;
|
||||
public $extension_dir;
|
||||
public static $theInstance;
|
||||
public static $ext_url;
|
||||
public $field_id = '';
|
||||
public $field = array();
|
||||
public $opt_name = '';
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param array $parent Parent settings.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $parent ) {
|
||||
|
||||
$redux_ver = ReduxFramework::$_version;
|
||||
|
||||
// Set parent object
|
||||
$this->parent = $parent;
|
||||
|
||||
// Set extension dir
|
||||
if ( empty( $this->extension_dir ) ) {
|
||||
$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
||||
$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
|
||||
self::$ext_url = $this->extension_url;
|
||||
}
|
||||
|
||||
// Set field name
|
||||
$this->field_name = 'social_profiles';
|
||||
|
||||
// Set instance
|
||||
self::$theInstance = $this;
|
||||
|
||||
// Adds the local field
|
||||
add_filter( 'redux/'.$this->parent->args['opt_name'].'/field/class/'. $this->field_name, array( &$this, 'overload_field_path' ) );
|
||||
|
||||
include_once('social_profiles/inc/defaults.php');
|
||||
include_once('social_profiles/inc/class.functions.php');
|
||||
|
||||
reduxSocialProfilesFunctions::init($parent);
|
||||
|
||||
$this->field = reduxSocialProfilesFunctions::getField($parent);
|
||||
//var_dump($this->field);
|
||||
//die();
|
||||
$this->field_id = $this->field['id'];
|
||||
$this->opt_name = $parent->args['opt_name'];
|
||||
|
||||
$upload_dir = reduxSocialProfilesFunctions::$upload_dir;
|
||||
|
||||
if (!is_dir($upload_dir)) {
|
||||
$parent->filesystem->execute('mkdir', $upload_dir );
|
||||
}
|
||||
|
||||
if (!class_exists('reduxLoadSocialWidget')) {
|
||||
$enable = apply_filters('redux/extensions/social_profiles/' . $this->opt_name . '/widget/enable', true);
|
||||
|
||||
if ($enable) {
|
||||
include_once('social_profiles/inc/widget.php');
|
||||
new reduxLoadSocialWidget($parent, $this->field_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('reduxSocialProfilesShortcode')) {
|
||||
$enable = apply_filters('redux/extensions/social_profiles/' . $this->opt_name . '/shortcode/enable', true);
|
||||
|
||||
if ($enable) {
|
||||
include_once('social_profiles/inc/shortcode.php');
|
||||
new reduxSocialProfilesShortcode($parent, $this->field_id);
|
||||
}
|
||||
}
|
||||
|
||||
add_action ( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
||||
|
||||
add_filter("redux/options/{$this->parent->args['opt_name']}/defaults", array($this, 'set_defaults'));
|
||||
add_action('redux/validate/' . $this->parent->args['opt_name'] . '/before_validation', array($this, 'save_me'), 0, 3);
|
||||
add_filter('redux/metaboxes/save/before_validate', array($this,'save_me'), 0, 3);
|
||||
|
||||
// Reset hooks
|
||||
add_action('redux/validate/' . $this->parent->args['opt_name'] . '/defaults', array($this, 'reset_defaults'), 0, 3);
|
||||
add_action('redux/validate/' . $this->parent->args['opt_name'] . '/defaults_section', array($this, 'reset_defaults_section'), 0, 3);
|
||||
|
||||
}
|
||||
|
||||
public function reset_defaults_section($defaults = array()) {
|
||||
|
||||
$curTab = $_COOKIE['redux_current_tab'];
|
||||
$tabNum = $this->parent->field_sections['social_profiles'][$this->field_id];
|
||||
|
||||
if ($curTab == $tabNum) {
|
||||
|
||||
if (!empty($this->field_id) && isset($this->parent->options_defaults[$this->field_id]) /* && !empty($this->parent->options_defaults[$this->field_id]) */) {
|
||||
$data = reduxSocialProfilesFunctions::get_default_data();
|
||||
|
||||
reduxSocialProfilesFunctions::write_data_file($data);
|
||||
}
|
||||
}
|
||||
|
||||
$defaults[$this->field_id] = reduxSocialProfilesFunctions::read_data_file();
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function reset_defaults($defaults = array()){
|
||||
if (!empty($this->field_id) && isset($this->parent->options_defaults[$this->field_id]) /*&& !empty($this->parent->options_defaults[$this->field_id])*/) {
|
||||
$data = reduxSocialProfilesFunctions::get_default_data();
|
||||
|
||||
reduxSocialProfilesFunctions::write_data_file($data);
|
||||
|
||||
$defaults[$this->field_id] = $data;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function set_defaults($defaults = array()) {
|
||||
if (empty($this->field_id)) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$comp_file = reduxSocialProfilesFunctions::get_data_path();
|
||||
|
||||
if (!file_exists($comp_file)){
|
||||
$data = reduxSocialProfilesFunctions::get_default_data();
|
||||
|
||||
reduxSocialProfilesFunctions::write_data_file($data);
|
||||
|
||||
$this->parent->options[$this->field_id] = $data;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function save_me($saved_options = array(), $changed_values = array()) {
|
||||
|
||||
if (empty($this->field)) {
|
||||
$this->field = reduxSocialProfilesFunctions::getField();
|
||||
$this->field_id = $this->field['id'];
|
||||
}
|
||||
|
||||
if ( !isset( $saved_options[$this->field_id] ) || empty( $saved_options[$this->field_id] ) || ( is_array( $saved_options[$this->field_id] ) && $changed_values == $saved_options ) || !array_key_exists ( $this->field_id, $saved_options ) ) {
|
||||
return $saved_options;
|
||||
}
|
||||
|
||||
// We'll use the reset hook instead
|
||||
if ( ! empty( $saved_options['defaults'] ) || !empty( $saved_options['defaults-section'] ) ) {
|
||||
return $saved_options;
|
||||
}
|
||||
|
||||
$first_value = reset($saved_options[$this->field_id]); // First Element's Value
|
||||
|
||||
if ( isset( $first_value['data'] ) ) {
|
||||
$raw_data = $saved_options[$this->field_id];
|
||||
|
||||
$save_data = array();
|
||||
|
||||
// Enum through saved data
|
||||
foreach($raw_data as $id => $val) {
|
||||
if (is_array($val)) {
|
||||
if (!isset($val['data'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode(rawurldecode($val['data']),true);
|
||||
|
||||
$save_data[] = array(
|
||||
'id' => $data['id'],
|
||||
'icon' => $data['icon'],
|
||||
'enabled' => $data['enabled'],
|
||||
'url' => $data['url'],
|
||||
'color' => $data['color'],
|
||||
'background' => $data['background'],
|
||||
'order' => $data['order'],
|
||||
'name' => $data['name'],
|
||||
'label' => $data['label'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$save_file = false;
|
||||
|
||||
if ( !isset( $old_options[$this->field_id] ) || ( isset( $old_options[$this->field_id] ) && !empty( $old_options[$this->field_id] ) ) ) {
|
||||
$save_file = true;
|
||||
}
|
||||
|
||||
if ( !empty( $old_options[$this->field_id] ) && $saved_options[$this->field_id] != $old_options[$this->field_id] ) {
|
||||
$save_file = true;
|
||||
}
|
||||
|
||||
if ($save_file) {
|
||||
reduxSocialProfilesFunctions::write_data_file($save_data);
|
||||
}
|
||||
//print_r($save_data);
|
||||
//die;
|
||||
$saved_options[$this->field_id] = $save_data;
|
||||
}
|
||||
|
||||
return $saved_options;
|
||||
}
|
||||
|
||||
public function enqueue_styles() {
|
||||
// Set up min files for dev_mode = false.
|
||||
$min = Redux_Functions::isMin();
|
||||
|
||||
// font-awesome
|
||||
wp_enqueue_style(
|
||||
'font-awesome',
|
||||
$this->extension_url . 'social_profiles/vendor/font-awesome' . $min . '.css',
|
||||
array(),
|
||||
time()
|
||||
);
|
||||
|
||||
// Field CSS
|
||||
wp_enqueue_style(
|
||||
'redux-field-social-profiles-frontend-css',
|
||||
$this->extension_url . 'social_profiles/css/field_social_profiles_frontend.css',
|
||||
array(),
|
||||
time()
|
||||
);
|
||||
}
|
||||
|
||||
static public function getInstance() {
|
||||
return self::$theInstance;
|
||||
}
|
||||
|
||||
static public function getExtURL() {
|
||||
return self::$ext_url;
|
||||
}
|
||||
|
||||
// Forces the use of the embeded field path vs what the core typically would use
|
||||
public function overload_field_path($field) {
|
||||
return dirname(__FILE__).'/'.$this->field_name.'/field_'.$this->field_name.'.php';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists ( 'redux_social_profile_value_from_id' )) {
|
||||
/**
|
||||
* Returns social profile value from passed profile ID.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $opt_name Redux Framework opt_name.
|
||||
* @param string $id Profile ID.
|
||||
* @param string $value Spcial profile value to return (icon, name, background, color, url, or order)
|
||||
* @return string Returns HTML string when $echo is set to false. Otherwise true.
|
||||
*/
|
||||
function redux_social_profile_value_from_id($opt_name, $id, $value) {
|
||||
if ( empty( $opt_name ) || empty( $id ) || empty( $value ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$redux = ReduxFrameworkInstances::get_instance( $opt_name );
|
||||
$social_profiles = $redux->extensions['social_profiles'];
|
||||
|
||||
$redux_options = get_option($social_profiles->opt_name);
|
||||
$settings = $redux_options[$social_profiles->field_id];
|
||||
|
||||
foreach($settings as $idx =>$arr) {
|
||||
if ($arr['id'] == $id) {
|
||||
if ($arr['enabled']) {
|
||||
if (isset($arr[$value])) {
|
||||
return $arr[$value];
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists ( 'redux_render_icon_from_id' )) {
|
||||
/**
|
||||
* Renders social icon from passed profile ID.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $opt_name Redux Framework opt_name.
|
||||
* @param string $id Profile ID.
|
||||
* @param boolean $echo Echos icon HTML when true. Returns icon HTML when false
|
||||
* @return string Returns HTML string when $echo is set to false. Otherwise true.
|
||||
*/
|
||||
function redux_render_icon_from_id($opt_name, $id, $echo = true, $a_class = '') {
|
||||
if ( empty( $opt_name ) || empty( $id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
include_once('social_profiles/inc/class.functions.php');
|
||||
|
||||
$redux = ReduxFrameworkInstances::get_instance( $opt_name );
|
||||
$social_profiles = $redux->extensions['social_profiles'];
|
||||
|
||||
$redux_options = get_option($social_profiles->opt_name);
|
||||
$settings = $redux_options[$social_profiles->field_id];
|
||||
|
||||
foreach($settings as $idx =>$arr) {
|
||||
if ($arr['id'] == $id) {
|
||||
if ($arr['enabled']) {
|
||||
|
||||
if ($echo) {
|
||||
echo '<a class="' . $a_class . '" href="' . $arr['url'] . '">';
|
||||
reduxSocialProfilesFunctions::render_icon($arr['icon'], $arr['color'], $arr['background'],'', true);
|
||||
echo '</a>';
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$html = '<a class="' . $a_class . '"href="' . $arr['url'] . '">';
|
||||
|
||||
$html .= reduxSocialProfilesFunctions::render_icon($arr['icon'], $arr['color'], $arr['background'],'', false);
|
||||
$html .= '</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
ul#redux-social-profiles-selector-list li.sortable-placeholder{width:40px;height:40px;line-height:40px;border:1px dashed gray;margin:0;padding:0;display:inline;float:left}ul#redux-social-profiles-list li{line-height:40px;height:100px;display:block;clear:left;padding-bottom:10px}.redux-icon-preview{float:left;display:block;font-size:30px;cursor:move;margin-right:10px}.redux-social-item-container{background-color:white;height:100%;border:#d8d8d8 1px solid}#redux-social-profiles-information{padding-bottom:10px}.redux-social-profiles-item-enabled{float:right !important;padding-right:10px;margin-top:-40px}.redux-social-profiles-selector-container{display:inline-block;padding-left:10px;padding-bottom:5px;padding-right:5px}li.redux-social-profiles-item-enable{display:block;float:left;font-size: 22px!important;cursor:pointer;width: 30px;height: 30px;line-height: 30px!important;padding:5px;text-align:center;border:1px solid transparent;color: #1f1f1f;}li.redux-social-profiles-item-enable.enabled{color:#555;border-color:#d8d8d8;background-color: #f4f4f4;}li.redux-social-profiles-item-enable:hover{background-color:#e5e5e5;color:#777;border-color:#d8d8d8}.redux-social-profiles-item-name{width:auto;font-size:150% !important}.redux-social-profiles-item-name .redux-text-name-label{font-size:150% !important}.redux-icon-preview,.redux-social-profiles-item-enable-item-name,.redux-social-profiles-item-enabled,.redux-social-profiles-text-color,.redux-social-profiles-background-color,.redux-social-profiles-link-url,.redux-social-profiles-item-order,.redux-social-profiles-item-reset{display:block;float:left;margin-left:10px;line-height:40px}.redux-social-profiles-text-color .redux-text-color-label{top:-30px;left:auto;width:0}.redux-social-profiles-background-color{padding-left:9px !important}.redux-social-profiles-background-color .redux-background-color-label{top:-30px;left:auto;width:0}.redux-social-profiles-item-order{display:none}.redux-social-profiles-item-order input{width:30px}.redux-social-profiles-item-reset{float:right;padding-right:10px;margin-top:15px}.redux-social-profiles-item-reset .button{margin-top:5px}.redux-social-profiles-link-url{clear:left !important;margin-top:-10px}.redux-social-profiles-link-url .redux-text-url-label{margin-bottom:3px !important}.redux-social-profiles-link-url input{width:100%;top:30px;left:0;position:absolute;width:100%}.redux-social-item-container label{display:block;position:relative;font-size:12px !important;text-align:left;color:#999;margin:4px 0 2px 0 !important;cursor:default}.redux-social-item-container .input_wrapper{display:block;position:relative;padding:0;width:54%;max-width:54%;min-width:70px;float:left;clear:none;height:57px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;vertical-align:baseline}.redux-social-item-container .input_wrapper.no-color-pickers{width:80%;max-width:80%}.redux-social-item-container .picker_wrapper{top:17px;display:block;position:relative;margin:0 4px 0 5px;margin:0;padding:0;padding-left:10px;clear:none;height:57px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;vertical-align:baseline}@media screen and (max-width:782px){ul#redux-social-profiles-list li{height:110px}.redux-social-item-container .picker_wrapper{top:20px !important}.redux-social-profiles-link-url .redux-text-url-label{margin-bottom:-16px !important}}@media screen and (max-width:628px){ul#redux-social-profiles-list li{height:170px}.redux-social-profiles-text-color{clear:both !important}.redux-social-item-container .picker_wrapper{top:30px}}
|
||||
.redux-social-profiles-background-color {display: none!important}
|
||||
@@ -0,0 +1,260 @@
|
||||
ul {
|
||||
&#redux-social-profiles-selector-list {
|
||||
li {
|
||||
&.sortable-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
border: 1px dashed gray;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: inline;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&#redux-social-profiles-list {
|
||||
li {
|
||||
line-height: 40px;
|
||||
height: 100px;
|
||||
display: block;
|
||||
clear: left;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.redux-icon-preview {
|
||||
float: left;
|
||||
display: block;
|
||||
font-size: 30px;
|
||||
cursor: move;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.redux-social-item-container {
|
||||
background-color: white;
|
||||
height: 100%;
|
||||
border: #D8D8D8 1px solid;
|
||||
}
|
||||
|
||||
#redux-social-profiles-information {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.redux-social-profiles-item-enabled {
|
||||
float: right !important;
|
||||
padding-right: 10px;
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
.redux-social-profiles-selector-container {
|
||||
display: inline-block;
|
||||
padding-left: 10px;
|
||||
padding-bottom: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
li {
|
||||
&.redux-social-profiles-item-enable {
|
||||
display: block;
|
||||
float: left;
|
||||
font-size: 30px;
|
||||
cursor: pointer;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
padding: 5px;
|
||||
padding-top: 0;
|
||||
text-align: center;
|
||||
border: 1px solid transparent;
|
||||
&.enabled {
|
||||
color: #555;
|
||||
border-color: #D8D8D8;
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
&:hover {
|
||||
background-color: #e5e5e5;
|
||||
color: #777;
|
||||
border-color: #D8D8D8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-item-name {
|
||||
width: auto;
|
||||
font-size: 150% !important;
|
||||
|
||||
.redux-text-name-label {
|
||||
font-size: 150% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-icon-preview,
|
||||
.redux-social-profiles-item-enable-item-name,
|
||||
.redux-social-profiles-item-enabled,
|
||||
.redux-social-profiles-text-color,
|
||||
.redux-social-profiles-background-color,
|
||||
.redux-social-profiles-link-url,
|
||||
.redux-social-profiles-item-order,
|
||||
.redux-social-profiles-item-reset {
|
||||
display: block;
|
||||
float: left;
|
||||
margin-left: 10px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.rdx-icon-preview input,
|
||||
.rdx-social-profiles-item-name input,
|
||||
.rdx-social-profiles-item-enabled input,
|
||||
.rdx-social-profiles-text-color div,
|
||||
.rdx-social-profiles-background-color div,
|
||||
.rdx-social-profiles-link-url input,
|
||||
.rdx-social-profiles-item-order input {
|
||||
/* margin-left: 5px;*/
|
||||
}
|
||||
|
||||
.redux-social-profiles-text-color {
|
||||
.redux-text-color-label {
|
||||
top: -30px;
|
||||
left: auto;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-background-color {
|
||||
padding-left: 9px !important;
|
||||
|
||||
.redux-background-color-label {
|
||||
top: -30px;
|
||||
left: auto;
|
||||
width: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-item-order {
|
||||
display: none;
|
||||
|
||||
input {
|
||||
width: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-item-reset {
|
||||
float: right;
|
||||
padding-right: 10px;
|
||||
margin-top: 15px;
|
||||
|
||||
.button {
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-link-url {
|
||||
clear: left !important;
|
||||
margin-top: -10px;
|
||||
|
||||
.redux-text-url-label {
|
||||
margin-bottom: 3px !important;
|
||||
}
|
||||
input {
|
||||
width: 100%;
|
||||
top: 30px;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-item-container {
|
||||
label {
|
||||
display: block;
|
||||
position: relative;
|
||||
font-size: 12px !important;
|
||||
text-align: left;
|
||||
color: #999999;
|
||||
margin: 4px 0 2px 0 !important;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.input_wrapper {
|
||||
display: block;
|
||||
position: relative;
|
||||
padding: 0;
|
||||
width: 54%;
|
||||
max-width: 54%;
|
||||
min-width: 70px;
|
||||
float: left;
|
||||
clear: none;
|
||||
height: 57px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
vertical-align: baseline;
|
||||
|
||||
&.no-color-pickers {
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
.picker_wrapper {
|
||||
top: 17px;
|
||||
display: block;
|
||||
position: relative;
|
||||
margin: 0 4px 0 5px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left: 10px;
|
||||
clear: none;
|
||||
height: 57px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
ul {
|
||||
&#redux-social-profiles-list {
|
||||
li {
|
||||
height: 110px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-item-container {
|
||||
.picker_wrapper {
|
||||
top: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-link-url {
|
||||
.redux-text-url-label {
|
||||
margin-bottom: -16px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 628px) {
|
||||
ul {
|
||||
&#redux-social-profiles-list {
|
||||
li {
|
||||
height: 170px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.redux-social-profiles-text-color {
|
||||
clear: both !important;
|
||||
}
|
||||
|
||||
.redux-social-item-container {
|
||||
.picker_wrapper {
|
||||
top: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
ul.redux-social-media-list{margin-top: 0;}ul.redux-social-media-list li{float:left;margin: 0;padding: 0;display:block;width: auto;}ul.redux-social-media-list li:before{content:''}
|
||||
|
||||
.footer_widget .redux-social-media-list a {
|
||||
font-size: 18px;
|
||||
border-radius: 90px;
|
||||
margin-right: 20px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
transition: .25s;
|
||||
margin: 0 20px 0 0;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.footer_widget .redux-social-media-list a:hover {
|
||||
opacity:0.8;
|
||||
-webkit-transform: translate3d(0,-3px,0);
|
||||
transform: translate3d(0,-3px,0);
|
||||
}
|
||||
|
||||
.footer_widget .redux-social-media-list i {
|
||||
margin:0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
ul {
|
||||
&.redux-social-media-list {
|
||||
margin-top: -20px;
|
||||
|
||||
li {
|
||||
font-size: 30px;
|
||||
float: left;
|
||||
margin-right: 2px;
|
||||
padding: 5px;
|
||||
display: block;
|
||||
|
||||
&:before {
|
||||
content: '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ul.redux-social-media-list{margin-top:0}ul.redux-social-media-list li{float:left;margin:0;padding:0;display:block;width:auto}ul.redux-social-media-list li:before{content:''}.footer_widget .redux-social-media-list a{font-size:18px;border-radius:90px;margin-right:20px;display:inline-block;text-align:center;transition:.25s;margin:0 20px 0 0;margin-bottom:8px}.footer_widget .redux-social-media-list a:hover{opacity:.8;-webkit-transform:translate3d(0,-3px,0);transform:translate3d(0,-3px,0)}.footer_widget .redux-social-media-list i{margin:0}
|
||||
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/**
|
||||
* Redux Framework is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
* Redux Framework is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Social Profiles
|
||||
* @author Kevin Provance (kprovance)
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Don't duplicate me!
|
||||
if ( ! class_exists( 'ReduxFramework_social_profiles' ) ) {
|
||||
|
||||
/**
|
||||
* Main ReduxFramework_spectrum class
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ReduxFramework_social_profiles {
|
||||
|
||||
public $field_id = '';
|
||||
public $opt_name = '';
|
||||
|
||||
/**
|
||||
* Class Constructor. Defines the args for the extions class
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $field Field sections.
|
||||
* @param array $value Values.
|
||||
* @param array $parent Parent object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $field = array(), $value = '', $parent ) {
|
||||
|
||||
// Set required variables
|
||||
$this->parent = $parent;
|
||||
$this->field = $field;
|
||||
$this->value = $value;
|
||||
|
||||
// Set extension dir & url
|
||||
if ( empty( $this->extension_dir ) ) {
|
||||
$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
|
||||
$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
|
||||
}
|
||||
|
||||
$this->opt_name = $parent->args['opt_name'];
|
||||
$this->field_id = $field['id'];
|
||||
|
||||
$this->defaults = reduxSocialProfilesFunctions::get_default_data();
|
||||
}
|
||||
|
||||
|
||||
private function rebuild_setttings($defaults, $settings){
|
||||
$fixed_arr = array();
|
||||
$stock = '';
|
||||
|
||||
foreach ( $this->defaults as $key => $arr ) {
|
||||
$search_default = true;
|
||||
|
||||
$default_id = $arr['id'];
|
||||
|
||||
foreach($settings as $i => $a){
|
||||
if ($a['id'] == $default_id) {
|
||||
$search_default = false;
|
||||
$fixed_arr[$key] = $a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($search_default) {
|
||||
if ($stock == ''){
|
||||
$stock = reduxSocialProfilesDefaults::get_social_media_defaults ();
|
||||
$stock = reduxSocialProfilesFunctions::add_extra_icons($stock);
|
||||
}
|
||||
|
||||
foreach($stock as $i => $def_arr) {
|
||||
if ($default_id == $def_arr['id']) {
|
||||
$fixed_arr[$key] = $def_arr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fixed_arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
global $pagenow, $post;
|
||||
$settings = '';
|
||||
|
||||
$redux_settings = get_option( $this->opt_name );
|
||||
$settings = isset($redux_settings[ $this->field_id ]) ? $redux_settings[ $this->field_id ] : array();
|
||||
|
||||
if ( is_admin() && ( $pagenow == "post-new.php" || $pagenow == "post.php" ) ) {
|
||||
$post_settings = get_post_meta($post->ID, $this->field_id, true);
|
||||
|
||||
if (!empty($post_settings)) {
|
||||
$settings = $post_settings;
|
||||
}
|
||||
}
|
||||
|
||||
$color_pickers = isset($this->field['color_pickers']) ? $this->field['color_pickers'] : true;
|
||||
|
||||
$dev_mode = $this->parent->args['dev_mode'];
|
||||
$dev_tag = '';
|
||||
|
||||
if ( true == $dev_mode ) {
|
||||
|
||||
$dev_tag = ' data-dev-mode="' . $this->parent->args['dev_mode'] . '"
|
||||
data-version="' . ReduxFramework_extension_social_profiles::$version . '"';
|
||||
}
|
||||
|
||||
// Icon container
|
||||
echo '<div
|
||||
class="redux-social-profiles-container ' . $this->field['class'] . '"
|
||||
data-opt-name="' . $this->opt_name . '"
|
||||
data-id="' . $this->field_id . '"' .
|
||||
$dev_tag . '
|
||||
>';
|
||||
|
||||
$show_msg = isset( $this->field['hide_widget_msg'] ) ? $this->field['hide_widget_msg'] : true;
|
||||
$msg = isset( $this->field['widget_msg'] ) ? $this->field['widget_msg'] : __( 'Go to the <a href="%s">Widgets</a> page to add the Redux Social Widget to any active widget area.', 'leadengine' );
|
||||
|
||||
if ( ! $show_msg ) {
|
||||
echo '<div class="redux-social-profiles-header">';
|
||||
printf( $msg, admin_url( 'widgets.php' ) );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="redux-social-profiles-selector-container">';
|
||||
echo '<ul id="redux-social-profiles-selector-list">';
|
||||
|
||||
$settings = $this->rebuild_setttings($this->defaults, $settings);
|
||||
|
||||
foreach ( $this->defaults as $key => $social_provider_default ) {
|
||||
$social_provider_option = ( $settings && is_array( $settings ) && array_key_exists( $key, $settings ) ) ? $settings[ $key ] : null;
|
||||
|
||||
$icon = ( $social_provider_option && array_key_exists( 'icon', $social_provider_option ) && $social_provider_option['icon'] ) ? $social_provider_option['icon'] : $social_provider_default['icon']; //$social_provider_default[ 'icon' ];
|
||||
$name = ( $social_provider_option && array_key_exists( 'name', $social_provider_option ) && $social_provider_option['name'] ) ? $social_provider_option['name'] : $social_provider_default['name']; //$social_provider_default[ 'name' ];
|
||||
$order = ( $social_provider_option && array_key_exists( 'order', $social_provider_option ) ) ? $social_provider_option['order'] : $key;
|
||||
$order = intval( $order );
|
||||
$enabled = ( $social_provider_option && array_key_exists( 'enabled', $social_provider_option ) && $social_provider_option['enabled'] ) ? $social_provider_option['enabled'] : $social_provider_default['enabled'];
|
||||
$display = ( $enabled ) ? 'enabled' : '';
|
||||
|
||||
echo '<li class="redux-social-profiles-item-enable ' . $display . '" id="redux-social-profiles-item-enable-' . $key . '" data-key="' . $key . '" data-order="' . $order . '">';
|
||||
reduxSocialProfilesFunctions::render_icon( $icon, '', '', $name );
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<ul id="redux-social-profiles-list">';
|
||||
|
||||
foreach ( $this->defaults as $key => $social_provider_default ) {
|
||||
echo '<li id="redux-social-item-' . $key . '" data-key="' . $key . '" style="display: none;">';
|
||||
echo '<div class="redux-social-item-container">';
|
||||
|
||||
|
||||
$social_provider_option = ( $settings && is_array( $settings ) && array_key_exists( $key, $settings ) ) ? $settings[ $key ] : null;
|
||||
$icon = ( $social_provider_option && array_key_exists( 'icon', $social_provider_option ) && $social_provider_option['icon'] ) ? $social_provider_option['icon'] : $social_provider_default['icon']; //$social_provider_default[ 'icon' ];
|
||||
$id = ( $social_provider_option && array_key_exists( 'id', $social_provider_option ) && $social_provider_option['id'] ) ? $social_provider_option['id'] : $social_provider_default['id']; //$social_provider_default[ 'id' ];
|
||||
$enabled = ( $social_provider_option && array_key_exists( 'enabled', $social_provider_option ) && $social_provider_option['enabled'] ) ? $social_provider_option['enabled'] : $social_provider_default['enabled'];
|
||||
$name = ( $social_provider_option && array_key_exists( 'name', $social_provider_option ) && $social_provider_option['name'] ) ? $social_provider_option['name'] : $social_provider_default['name']; //$social_provider_default[ 'name' ];
|
||||
|
||||
$label = ( $social_provider_option && array_key_exists( 'label', $social_provider_option ) && $social_provider_option['label'] ) ? $social_provider_option['label'] : __( 'Link URL', 'leadengine' ); //$social_provider_default[ 'name' ];
|
||||
|
||||
$color = ( $social_provider_option && array_key_exists( 'color', $social_provider_option ) ) ? $social_provider_option['color'] : $social_provider_default['color'];
|
||||
$color = esc_attr( $color );
|
||||
|
||||
$background = ( $social_provider_option && array_key_exists( 'background', $social_provider_option ) ) ? $social_provider_option['background'] : $social_provider_default['background'];
|
||||
$background = esc_attr( $background );
|
||||
|
||||
$order = ( $social_provider_option && array_key_exists( 'order', $social_provider_option ) ) ? $social_provider_option['order'] : $key;
|
||||
$order = intval( $order );
|
||||
|
||||
$url = ( $social_provider_option && array_key_exists( 'url', $social_provider_option ) ) ? $social_provider_option['url'] : $social_provider_default['url'];
|
||||
$url = esc_attr( $url );
|
||||
|
||||
$profile_data = array(
|
||||
'id' => $id,
|
||||
'icon' => $icon,
|
||||
'enabled' => $enabled,
|
||||
'url' => $url,
|
||||
'color' => $color,
|
||||
'background' => $background,
|
||||
'order' => $order,
|
||||
'name' => $name,
|
||||
'label' => $label
|
||||
);
|
||||
|
||||
$profile_data = rawurlencode( json_encode( $profile_data ) );
|
||||
|
||||
echo
|
||||
'<input
|
||||
type="hidden"
|
||||
class="redux-social-profiles-hidden-data-' . $key . '"
|
||||
id="' . $this->field_id . '-' . $id . '-data"
|
||||
name="' . $this->opt_name . '[' . $this->field_id . '][' . $key . '][data]"
|
||||
value="' . $profile_data . '"
|
||||
/>';
|
||||
|
||||
echo '<div class="redux-icon-preview">';
|
||||
reduxSocialProfilesFunctions::render_icon( $icon, $color, $background, $name );
|
||||
echo ' </div>';
|
||||
|
||||
echo '<div class="redux-social-profiles-item-name">';
|
||||
echo $name;
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="redux-social-profiles-item-enabled">';
|
||||
$checked = ( $enabled ) ? 'checked' : '';
|
||||
echo '<input type="checkbox" class="checkbox-' . $key . '" data-key="' . $key . '" value="1" ' . $checked . '/>';
|
||||
_e( 'Enabled', 'leadengine' );
|
||||
echo '</div>';
|
||||
|
||||
$color_class = $color_pickers ? '' : ' no-color-pickers';
|
||||
|
||||
echo '<div class="redux-social-profiles-link-url input_wrapper' . $color_class . '">';
|
||||
echo '<label class="redux-text-url-label">' . $label . '</label>';
|
||||
echo '<input class="redux-social-profiles-url-text" data-key="' . $key . '" type="text" value="' . $url . '" />';
|
||||
echo '</div>';
|
||||
|
||||
$reset_text = __( 'Reset', 'leadengine' );
|
||||
echo '<div class="redux-social-profiles-item-reset">';
|
||||
echo '<a class="button" data-value="' . $key . '" value="' . $reset_text . '" />' . $reset_text . '</a>';
|
||||
echo '</div>';
|
||||
|
||||
if ($color_pickers) {
|
||||
$label = apply_filters('redux/extensions/social_profiles/' . $this->opt_name . '/color_picker/text', __( 'Text', 'leadengine' ));
|
||||
|
||||
echo '<div class="redux-social-profiles-text-color picker_wrapper" >';
|
||||
echo '<label class="redux-text-color-label">' .$label . '</label>';
|
||||
echo
|
||||
'<input
|
||||
class="redux-social-profiles-color-picker-' . $key . ' text"
|
||||
type="text"
|
||||
value="' . $color . '"
|
||||
data-key="' . $key . '"
|
||||
/>';
|
||||
echo "</div>";
|
||||
|
||||
$label = apply_filters('redux/extensions/social_profiles/' . $this->opt_name . '/color_picker/background', __( 'Background', 'leadengine' ));
|
||||
|
||||
echo '<div class="redux-social-profiles-background-color picker_wrapper">';
|
||||
echo '<label class="redux-background-color-label">' . $label . '</label>';
|
||||
echo
|
||||
'<input
|
||||
class="redux-social-profiles-color-picker-' . $key . ' background"
|
||||
type="text"
|
||||
value="' . $background . '"
|
||||
data-key="' . $key . '"
|
||||
/>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="redux-social-profiles-item-order">';
|
||||
echo
|
||||
'<input
|
||||
type="hidden"
|
||||
value="' . $order . '"
|
||||
/>';
|
||||
echo "</div>";
|
||||
|
||||
echo '</div>';
|
||||
echo "</li>";
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output Function.
|
||||
* Used to enqueue to the front-end
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function output() {
|
||||
if ( ! empty( $this->value ) ) {
|
||||
foreach ( $this->value as $idx => $arr ) {
|
||||
if ( $arr['enabled'] ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Function.
|
||||
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
$extension = ReduxFramework_extension_social_profiles::getInstance();
|
||||
|
||||
// Set up min files for dev_mode = false.
|
||||
$min = Redux_Functions::isMin();
|
||||
|
||||
// font-awesome
|
||||
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/core/assets/css/font-awesome.min.css', '', '' );
|
||||
|
||||
// Field dependent JS
|
||||
wp_enqueue_script( 'redux-field-social-profiles-js', plugins_url('js/field_social_profiles.min.js', __FILE__), array('jquery', 'jquery-ui-sortable', 'redux-spectrum-js', 'redux-js'), time(), true );
|
||||
|
||||
wp_localize_script(
|
||||
'redux-field-social-profiles-js',
|
||||
'reduxSocialDefaults',
|
||||
$this->defaults
|
||||
);
|
||||
|
||||
// Field CSS
|
||||
wp_enqueue_style( 'redux-field-social-profiles-css', plugins_url('css/field_social_profiles.css', __FILE__), array('redux-spectrum-css'), 'all' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !class_exists ( 'reduxSocialProfilesFunctions' ) ) {
|
||||
|
||||
class reduxSocialProfilesFunctions {
|
||||
static public $_parent;
|
||||
static public $_field_id;
|
||||
static public $_field;
|
||||
static public $upload_dir;
|
||||
static public $upload_url;
|
||||
|
||||
public static function init($parent){
|
||||
self::$_parent = $parent;
|
||||
|
||||
if(empty( self::$_field_id )) {
|
||||
self::$_field = self::getField($parent);
|
||||
self::$_field_id = self::$_field['id'];
|
||||
}
|
||||
|
||||
// Make sanitized upload dir DIR
|
||||
self::$upload_dir = Redux_Helpers::cleanFilePath(ReduxFramework::$_upload_dir . 'social-profiles/');
|
||||
|
||||
// Make sanitized upload dir URL
|
||||
self::$upload_url = Redux_Helpers::cleanFilePath(ReduxFramework::$_upload_url . 'social-profiles/');
|
||||
|
||||
Redux_Functions::initWpFilesystem();
|
||||
}
|
||||
|
||||
public static function read_data_file() {
|
||||
$file = self::get_data_path();
|
||||
|
||||
if (file_exists($file)){
|
||||
|
||||
// Get the contents of the file and stuff it in a variable
|
||||
$data = self::$_parent->filesystem->execute('get_contents', $file);
|
||||
|
||||
// Error or null, set the result to false
|
||||
if (false == $data || null == $data){
|
||||
$arrData = false;
|
||||
|
||||
// Otherwise decode the json object and return it.
|
||||
} else {
|
||||
$arr = json_decode($data, true);
|
||||
$arrData = $arr;
|
||||
}
|
||||
} else {
|
||||
$arrData = false;
|
||||
}
|
||||
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
public static function write_data_file($arrData, $file = '') {
|
||||
if (!is_dir(self::$upload_dir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = ('' === $file) ? self::get_data_path() : self::$upload_dir . $file;
|
||||
|
||||
// Encode the array data
|
||||
$data = json_encode($arrData);
|
||||
|
||||
// Write to its file on the server, return the return value
|
||||
// True on success, false on error.
|
||||
$ret_val = self::$_parent->filesystem->execute('put_contents', $file, array('content' => $data));
|
||||
|
||||
return $ret_val;
|
||||
|
||||
}
|
||||
|
||||
public static function get_data_path(){
|
||||
return Redux_Helpers::cleanFilePath(self::$upload_dir . '/' . self::$_parent->args['opt_name'] . '-' . self::$_field_id . '.json');
|
||||
}
|
||||
|
||||
public static function getField($parent = array()) {
|
||||
global $pagenow, $post;
|
||||
|
||||
if ( is_admin() && ( $pagenow == "post-new.php" || $pagenow == "post.php" ) ) {
|
||||
|
||||
$inst = ReduxFrameworkInstances::get_instance(self::$_parent->args['opt_name']);
|
||||
|
||||
$ext = $inst->extensions;
|
||||
|
||||
if (isset($ext['metaboxes'])) {
|
||||
$obj = $ext['metaboxes'];
|
||||
$boxes = ($obj->boxes);
|
||||
|
||||
if (isset($post->post_type)) {
|
||||
foreach($boxes as $idx => $sections){
|
||||
foreach ($sections['sections'] as $i => $fields) {
|
||||
foreach ($fields['fields'] as $n => $f) {
|
||||
if ($f['type'] == 'social_profiles' && in_array($post->post_type , $sections['post_types'] ) ) {
|
||||
return $f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($parent)) {
|
||||
self::$_parent = $parent;
|
||||
}
|
||||
|
||||
if (isset(self::$_parent->field_sections['social_profiles'])) {
|
||||
return reset(self::$_parent->field_sections['social_profiles']);
|
||||
}
|
||||
|
||||
$arr = self::$_parent;
|
||||
|
||||
foreach($arr as $part => $bla) {
|
||||
if ($part == 'sections') {
|
||||
foreach($bla as $section => $field) {
|
||||
|
||||
foreach($field as $arg => $val){
|
||||
if ($arg == 'fields') {
|
||||
foreach($val as $k => $v) {
|
||||
foreach($v as $id => $x) {
|
||||
if ($id == 'type') {
|
||||
if ($x == 'social_profiles') {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function add_extra_icons($defaults){
|
||||
if (empty(self::$_field)) {
|
||||
self::$_field = self::getField();
|
||||
}
|
||||
|
||||
if (isset(self::$_field['icons']) && !empty(self::$_field['icons'])) {
|
||||
$cur_count = count($defaults);
|
||||
|
||||
foreach(self::$_field['icons'] as $idx => $arr) {
|
||||
|
||||
$skip_add = false;
|
||||
foreach($defaults as $i => $v) {
|
||||
if ($arr['id'] == $v['id']) {
|
||||
|
||||
$defaults[$i] = array_replace($defaults[$i], $arr);
|
||||
$skip_add = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$skip_add) {
|
||||
$arr['order'] = $cur_count;
|
||||
$defaults[$cur_count] = $arr;
|
||||
$cur_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
private static function get_includes($val) {
|
||||
if (empty(self::$_field)) {
|
||||
self::$_field = self::getField();
|
||||
}
|
||||
|
||||
if (isset(self::$_field['include']) && is_array(self::$_field['include']) && !empty(self::$_field['include'])) {
|
||||
$icons = self::$_field['include'];
|
||||
//var_dump($icons);
|
||||
//var_dump($val);
|
||||
$new_arr = array();
|
||||
|
||||
$idx = 0;
|
||||
foreach($val as $arr) {
|
||||
foreach($icons as $icon) {
|
||||
if ( $arr['id'] == $icon ) {
|
||||
$arr['order'] = $idx;
|
||||
$new_arr[$idx] = $arr;
|
||||
$idx++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$new_arr = $val;
|
||||
}
|
||||
|
||||
return $new_arr;
|
||||
|
||||
}
|
||||
|
||||
public static function get_default_data() {
|
||||
$data = reduxSocialProfilesDefaults::get_social_media_defaults ();
|
||||
$data = self::get_includes($data);
|
||||
$data = self::add_extra_icons($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* static function to render the social icon
|
||||
*/
|
||||
public static function render_icon ( $icon, $color, $background, $title, $echo = true ) {
|
||||
if ( $color || $background ) {
|
||||
if ($color == '') {
|
||||
$color = 'transparent';
|
||||
}
|
||||
|
||||
if ($background == '') {
|
||||
$background = 'transparent';
|
||||
}
|
||||
|
||||
$inline = "style='color:" . $color . ";background-color:" . $background . ";'";
|
||||
} else {
|
||||
$inline = "";
|
||||
}
|
||||
|
||||
$str = '<i class="fa ' . $icon . '" ' . $inline . ' title="' . $title . '"></i>';
|
||||
|
||||
if ($echo) {
|
||||
echo $str;
|
||||
} else {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,859 @@
|
||||
<?php
|
||||
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !class_exists ( 'reduxSocialProfilesDefaults' ) ) {
|
||||
|
||||
class reduxSocialProfilesDefaults {
|
||||
|
||||
public static function get_social_media_defaults () {
|
||||
$defaults = array(
|
||||
0 => array(
|
||||
'id' => 'adn',
|
||||
'icon' => 'fa-adn',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'ADN', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 0,
|
||||
),
|
||||
1 => array(
|
||||
'id' => 'android',
|
||||
'icon' => 'fa-android',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Android', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#A4C639',
|
||||
'url' => '',
|
||||
'order' => 1,
|
||||
),
|
||||
2 => array(
|
||||
'id' => 'apple',
|
||||
'icon' => 'fa-apple',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Apple', 'ekko' ),
|
||||
'style' => '',
|
||||
'background' => '',
|
||||
'color' => '#e4e4e5',
|
||||
'url' => '',
|
||||
'order' => 2,
|
||||
),
|
||||
3 => array(
|
||||
'id' => 'behance',
|
||||
'icon' => 'fa-behance',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'behance', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#1769ff',
|
||||
'url' => '',
|
||||
'order' => 3,
|
||||
),
|
||||
4 => array(
|
||||
'id' => 'behance-square',
|
||||
'icon' => 'fa-behance-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'behance square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#1769ff',
|
||||
'url' => '',
|
||||
'order' => 4,
|
||||
),
|
||||
5 => array(
|
||||
'id' => 'bitbucket',
|
||||
'icon' => 'fa-bitbucket',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Bitbucket', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#205081',
|
||||
'url' => '',
|
||||
'order' => 5,
|
||||
),
|
||||
6 => array(
|
||||
'id' => 'bitbucket-square',
|
||||
'icon' => 'fa-bitbucket-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Bitbucket square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#205081',
|
||||
'url' => '',
|
||||
'order' => 6,
|
||||
),
|
||||
7 => array(
|
||||
'id' => 'bitcoin',
|
||||
'icon' => 'fa-btc',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Bitcoin', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 7,
|
||||
),
|
||||
8 => array(
|
||||
'id' => 'codepen',
|
||||
'icon' => 'fa-codepen',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'CodePen', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 8,
|
||||
),
|
||||
9 => array(
|
||||
'id' => 'css3',
|
||||
'icon' => 'fa-css3',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'CSS3', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 9,
|
||||
),
|
||||
10 => array(
|
||||
'id' => 'delicious',
|
||||
'icon' => 'fa-delicious',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Delicious', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#3399ff',
|
||||
'url' => '',
|
||||
'order' => 10,
|
||||
),
|
||||
11 => array(
|
||||
'id' => 'deviantart',
|
||||
'icon' => 'fa-deviantart',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Deviantart', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#4e6252',
|
||||
'url' => '',
|
||||
'order' => 11,
|
||||
),
|
||||
12 => array(
|
||||
'id' => 'digg',
|
||||
'icon' => 'fa-digg',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Digg', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 12,
|
||||
),
|
||||
13 => array(
|
||||
'id' => 'dribbble',
|
||||
'icon' => 'fa-dribbble',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Dribbble', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#444444',
|
||||
'url' => '',
|
||||
'order' => 13,
|
||||
),
|
||||
14 => array(
|
||||
'id' => 'dropbox',
|
||||
'icon' => 'fa-dropbox',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Dropbox', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#007ee5',
|
||||
'url' => '',
|
||||
'order' => 14,
|
||||
),
|
||||
15 => array(
|
||||
'id' => 'drupal',
|
||||
'icon' => 'fa-drupal',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Drupal', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0077c0',
|
||||
'url' => '',
|
||||
'order' => 15,
|
||||
),
|
||||
16 => array(
|
||||
'id' => 'empire',
|
||||
'icon' => 'fa-empire',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Empire', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 16,
|
||||
),
|
||||
17 => array(
|
||||
'id' => 'facebook',
|
||||
'icon' => 'fa-facebook',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Facebook', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#3b5998',
|
||||
'url' => '',
|
||||
'order' => 17,
|
||||
),
|
||||
18 => array(
|
||||
'id' => 'facebook-square',
|
||||
'icon' => 'fa-facebook-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Facebook square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#3b5998',
|
||||
'url' => '',
|
||||
'order' => 18,
|
||||
),
|
||||
19 => array(
|
||||
'id' => 'flickr',
|
||||
'icon' => 'fa-flickr',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Flickr', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0063dc',
|
||||
'url' => '',
|
||||
'order' => 19,
|
||||
),
|
||||
20 => array(
|
||||
'id' => 'foursquare',
|
||||
'icon' => 'fa-foursquare',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'FourSquare', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0072b1',
|
||||
'url' => '',
|
||||
'order' => 20,
|
||||
),
|
||||
21 => array(
|
||||
'id' => 'git',
|
||||
'icon' => 'fa-git',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'git', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 21,
|
||||
),
|
||||
22 => array(
|
||||
'id' => 'git-square',
|
||||
'icon' => 'fa-git-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'git square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 22,
|
||||
),
|
||||
23 => array(
|
||||
'id' => 'github',
|
||||
'icon' => 'fa-github',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'github', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#4183c4',
|
||||
'url' => '',
|
||||
'order' => 23,
|
||||
),
|
||||
24 => array(
|
||||
'id' => 'github-alt',
|
||||
'icon' => 'fa-github-alt',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'github alt', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#4183c4',
|
||||
'url' => '',
|
||||
'order' => 24,
|
||||
),
|
||||
25 => array(
|
||||
'id' => 'github-square',
|
||||
'icon' => 'fa-github-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'github square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#4183c4',
|
||||
'url' => '',
|
||||
'order' => 25,
|
||||
),
|
||||
26 => array(
|
||||
'id' => 'gittip',
|
||||
'icon' => 'fa-gittip',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'git tip', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 26,
|
||||
),
|
||||
27 => array(
|
||||
'id' => 'google',
|
||||
'icon' => 'fa-google',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Google', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#dd4b39',
|
||||
'url' => '',
|
||||
'order' => 27,
|
||||
),
|
||||
28 => array(
|
||||
'id' => 'google-plus',
|
||||
'icon' => 'fa-google-plus',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Google Plus', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#dd4b39',
|
||||
'url' => '',
|
||||
'order' => 28,
|
||||
),
|
||||
29 => array(
|
||||
'id' => 'google-plus-square',
|
||||
'icon' => 'fa-google-plus-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Google Plus square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#dd4b39',
|
||||
'url' => '',
|
||||
'order' => 29,
|
||||
),
|
||||
30 => array(
|
||||
'id' => 'hacker-news',
|
||||
'icon' => 'fa-hacker-news',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Hacker News', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#ff6600',
|
||||
'url' => '',
|
||||
'order' => 30,
|
||||
),
|
||||
31 => array(
|
||||
'id' => 'html5',
|
||||
'icon' => 'fa-html5',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'HTML5', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#e34f26',
|
||||
'url' => '',
|
||||
'order' => 31,
|
||||
),
|
||||
32 => array(
|
||||
'id' => 'instagram',
|
||||
'icon' => 'fa-instagram',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Instagram', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#3f729b',
|
||||
'url' => '',
|
||||
'order' => 32,
|
||||
),
|
||||
33 => array(
|
||||
'id' => 'joomla',
|
||||
'icon' => 'fa-joomla',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Joomla', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 33,
|
||||
),
|
||||
34 => array(
|
||||
'id' => 'jsfiddle',
|
||||
'icon' => 'fa-jsfiddle',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'JS Fiddle', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 34,
|
||||
),
|
||||
35 => array(
|
||||
'id' => 'linkedin',
|
||||
'icon' => 'fa-linkedin',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'LinkedIn', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0976b4',
|
||||
'url' => '',
|
||||
'order' => 35,
|
||||
),
|
||||
36 => array(
|
||||
'id' => 'linkedin-square',
|
||||
'icon' => 'fa-linkedin-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'LinkedIn square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0976b4',
|
||||
'url' => '',
|
||||
'order' => 36,
|
||||
),
|
||||
37 => array(
|
||||
'id' => 'linux',
|
||||
'icon' => 'fa-linux',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Linux', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#333333',
|
||||
'url' => '',
|
||||
'order' => 37,
|
||||
),
|
||||
38 => array(
|
||||
'id' => 'maxcdn',
|
||||
'icon' => 'fa-maxcdn',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'MaxCDN', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#f8711e',
|
||||
'url' => '',
|
||||
'order' => 38,
|
||||
),
|
||||
39 => array(
|
||||
'id' => 'openid',
|
||||
'icon' => 'fa-openid',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'OpenID', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 39,
|
||||
),
|
||||
40 => array(
|
||||
'id' => 'pagelines',
|
||||
'icon' => 'fa-pagelines',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Page Lines', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 40,
|
||||
),
|
||||
41 => array(
|
||||
'id' => 'pied-piper',
|
||||
'icon' => 'fa-pied-piper',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Pied Piper', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 41,
|
||||
),
|
||||
42 => array(
|
||||
'id' => 'pied-piper-alt',
|
||||
'icon' => 'fa-pied-piper-alt',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Pied Piper alt', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 42,
|
||||
),
|
||||
43 => array(
|
||||
'id' => 'pinterest',
|
||||
'icon' => 'fa-pinterest',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Pinterest', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#1769ff',
|
||||
'url' => '',
|
||||
'order' => 43,
|
||||
),
|
||||
44 => array(
|
||||
'id' => 'pinterest-square',
|
||||
'icon' => 'fa-pinterest-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Pinterest square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#1769ff',
|
||||
'url' => '',
|
||||
'order' => 44,
|
||||
),
|
||||
45 => array(
|
||||
'id' => 'qq',
|
||||
'icon' => 'fa-qq',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'QQ', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 45,
|
||||
),
|
||||
46 => array(
|
||||
'id' => 'rebel',
|
||||
'icon' => 'fa-rebel',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Rebel', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#517fa4',
|
||||
'url' => '',
|
||||
'order' => 46,
|
||||
),
|
||||
47 => array(
|
||||
'id' => 'reddit',
|
||||
'icon' => 'fa-reddit',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Reddit', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#ff4500',
|
||||
'url' => '',
|
||||
'order' => 47,
|
||||
),
|
||||
48 => array(
|
||||
'id' => 'reddit-square',
|
||||
'icon' => 'fa-reddit-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Reddit square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#ff4500',
|
||||
'url' => '',
|
||||
'order' => 48,
|
||||
),
|
||||
49 => array(
|
||||
'id' => 'renren',
|
||||
'icon' => 'fa-renren',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Ren Ren', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#007bb6',
|
||||
'url' => '',
|
||||
'order' => 49,
|
||||
),
|
||||
50 => array(
|
||||
'id' => 'share-alt',
|
||||
'icon' => 'fa-share-alt',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Share alt', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 50,
|
||||
),
|
||||
51 => array(
|
||||
'id' => 'share-alt-square',
|
||||
'icon' => 'fa-share-alt-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Share square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 51,
|
||||
),
|
||||
52 => array(
|
||||
'id' => 'skype',
|
||||
'icon' => 'fa-skype',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Skype', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#00aff0',
|
||||
'url' => '',
|
||||
'order' => 52,
|
||||
),
|
||||
53 => array(
|
||||
'id' => 'slack',
|
||||
'icon' => 'fa-slack',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Slack', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 53,
|
||||
),
|
||||
54 => array(
|
||||
'id' => 'soundcloud',
|
||||
'icon' => 'fa-soundcloud',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Sound Cloud', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#f80',
|
||||
'url' => '',
|
||||
'order' => 54,
|
||||
),
|
||||
55 => array(
|
||||
'id' => 'spotify',
|
||||
'icon' => 'fa-spotify',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Spotify', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#7ab800',
|
||||
'url' => '',
|
||||
'order' => 55,
|
||||
),
|
||||
56 => array(
|
||||
'id' => 'stack-exchange',
|
||||
'icon' => 'fa-stack-exchange',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Stack Exchange', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 56,
|
||||
),
|
||||
57 => array(
|
||||
'id' => 'stack-overflow',
|
||||
'icon' => 'fa-stack-overflow',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Stack Overflow', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#fe7a15',
|
||||
'url' => '',
|
||||
'order' => 57,
|
||||
),
|
||||
58 => array(
|
||||
'id' => 'steam',
|
||||
'icon' => 'fa-steam',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Steam', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 58,
|
||||
),
|
||||
59 => array(
|
||||
'id' => 'steam-square',
|
||||
'icon' => 'fa-steam-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Steam square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 59,
|
||||
),
|
||||
60 => array(
|
||||
'id' => 'stumbleupon',
|
||||
'icon' => 'fa-stumbleupon',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Stumble Upon', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#eb4924',
|
||||
'url' => '',
|
||||
'order' => 60,
|
||||
),
|
||||
61 => array(
|
||||
'id' => 'stumbleupon-circle',
|
||||
'icon' => 'fa-stumbleupon-circle',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Stumble Upon circle', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#eb4924',
|
||||
'url' => '',
|
||||
'order' => 61,
|
||||
),
|
||||
62 => array(
|
||||
'id' => 'tencent-weibo',
|
||||
'icon' => 'fa-tencent-weibo',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Tencent Weibo', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 62,
|
||||
),
|
||||
63 => array(
|
||||
'id' => 'trello',
|
||||
'icon' => 'fa-trello',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Trello', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#256a92',
|
||||
'url' => '',
|
||||
'order' => 63,
|
||||
),
|
||||
64 => array(
|
||||
'id' => 'twitter',
|
||||
'icon' => 'fa-twitter',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Twitter', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#55acee',
|
||||
'url' => '',
|
||||
'order' => 64,
|
||||
),
|
||||
65 => array(
|
||||
'id' => 'twitter-square',
|
||||
'icon' => 'fa-twitter-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Twitter square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#55acee',
|
||||
'url' => '',
|
||||
'order' => 65,
|
||||
),
|
||||
66 => array(
|
||||
'id' => 'vimeo-square',
|
||||
'icon' => 'fa-vimeo-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Vimeo square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#1ab7ea',
|
||||
'url' => '',
|
||||
'order' => 66,
|
||||
),
|
||||
67 => array(
|
||||
'id' => 'vine',
|
||||
'icon' => 'fa-vine',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Vine', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#00b488',
|
||||
'url' => '',
|
||||
'order' => 67,
|
||||
),
|
||||
68 => array(
|
||||
'id' => 'vk',
|
||||
'icon' => 'fa-vk',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'VK', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 68,
|
||||
),
|
||||
69 => array(
|
||||
'id' => 'weibo',
|
||||
'icon' => 'fa-weibo',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Weibo', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 69,
|
||||
),
|
||||
70 => array(
|
||||
'id' => 'weixin',
|
||||
'icon' => 'fa-weixin',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Weixin', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#000000',
|
||||
'url' => '',
|
||||
'order' => 70,
|
||||
),
|
||||
71 => array(
|
||||
'id' => 'windows',
|
||||
'icon' => 'fa-windows',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Windows', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#00bcf2',
|
||||
'url' => '',
|
||||
'order' => 71,
|
||||
),
|
||||
72 => array(
|
||||
'id' => 'wordpress',
|
||||
'icon' => 'fa-wordpress',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'WordPress', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#21759b',
|
||||
'url' => '',
|
||||
'order' => 72,
|
||||
),
|
||||
73 => array(
|
||||
'id' => 'xing',
|
||||
'icon' => 'fa-xing',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Xing', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#026466',
|
||||
'url' => '',
|
||||
'order' => 73,
|
||||
),
|
||||
74 => array(
|
||||
'id' => 'xing-square',
|
||||
'icon' => 'fa-xing-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Xing square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#026466',
|
||||
'url' => '',
|
||||
'order' => 74,
|
||||
),
|
||||
75 => array(
|
||||
'id' => 'yahoo',
|
||||
'icon' => 'fa-yahoo',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Yahoo', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#400191',
|
||||
'url' => '',
|
||||
'order' => 75,
|
||||
),
|
||||
76 => array(
|
||||
'id' => 'yelp',
|
||||
'icon' => 'fa-yelp',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Yelp', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#C93C27',
|
||||
'url' => '',
|
||||
'order' => 76,
|
||||
),
|
||||
77 => array(
|
||||
'id' => 'youtube',
|
||||
'icon' => 'fa-youtube',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'YouTube', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#e52d27',
|
||||
'url' => '',
|
||||
'order' => 77,
|
||||
),
|
||||
78 => array(
|
||||
'id' => 'youtube-play',
|
||||
'icon' => 'fa-youtube-play',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'YouTube play', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#e52d27',
|
||||
'url' => '',
|
||||
'order' => 78,
|
||||
),
|
||||
79 => array(
|
||||
'id' => 'youtube-square',
|
||||
'icon' => 'fa-youtube-square',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'YouTube square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#e52d27',
|
||||
'url' => '',
|
||||
'order' => 79,
|
||||
),
|
||||
80 => array(
|
||||
'id' => 'whatsapp',
|
||||
'icon' => 'fa-whatsapp',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'WhatsApp', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#25D366',
|
||||
'url' => '',
|
||||
'order' => 80,
|
||||
),
|
||||
81 => array(
|
||||
'id' => 'telegram',
|
||||
'icon' => 'fa-telegram',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Telegram', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#0088cc',
|
||||
'url' => '',
|
||||
'order' => 81,
|
||||
),
|
||||
82 => array(
|
||||
'id' => 'tripadvisor',
|
||||
'icon' => 'fa-tripadvisor',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'TripAdvisor', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#00af87',
|
||||
'url' => '',
|
||||
'order' => 82,
|
||||
),
|
||||
83 => array(
|
||||
'id' => 'medium',
|
||||
'icon' => 'fa-medium',
|
||||
'enabled' => false,
|
||||
'name' => __ ( 'Medium Square', 'ekko' ),
|
||||
'background' => '',
|
||||
'color' => '#00ab6c',
|
||||
'url' => '',
|
||||
'order' => 83,
|
||||
),
|
||||
);
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !class_exists ( 'reduxSocialProfilesShortcode' ) ) {
|
||||
|
||||
class reduxSocialProfilesShortcode {
|
||||
|
||||
private $parent = null;
|
||||
private $field_id = '';
|
||||
|
||||
public function __construct ($parent, $field_id) {
|
||||
$this->parent = $parent;
|
||||
$this->field_id = $field_id;
|
||||
|
||||
add_shortcode ( 'social_profiles', array( $this, 'redux_social_profiles' ),1 );
|
||||
}
|
||||
|
||||
public function redux_social_profiles ( $atts, $content = null ) {
|
||||
// extract ( shortcode_atts ( array(
|
||||
// "type" => "info"
|
||||
// ), $atts ) );
|
||||
|
||||
//return '<div class="alert ' . $type . '">' . do_shortcode ( $content ) . '</div>';
|
||||
$redux_options = get_option($this->parent->args['opt_name']);
|
||||
$social_items = $redux_options[$this->field_id];
|
||||
|
||||
$html = '';
|
||||
|
||||
$html .= '<ul class="redux-social-media-list clearfix">';
|
||||
if ( is_array ( $social_items ) ) {
|
||||
foreach ( $social_items as $key => $social_item ) {
|
||||
if ( $social_item[ 'enabled' ] ) {
|
||||
$icon = $social_item[ 'icon' ];
|
||||
$color = $social_item[ 'color' ];
|
||||
$background = $social_item[ 'background' ];
|
||||
$base_url = $social_item[ 'url' ];
|
||||
$id = $social_item['id'];
|
||||
|
||||
$url = apply_filters('redux/extensions/social_profiles/' . $this->parent->args['opt_name'] . '/icon_url', $id, $base_url);
|
||||
|
||||
$html .= '<li style="list-style: none;">';
|
||||
$html .= "<a target='_blank' href='" . $base_url . "'>";
|
||||
$html .= reduxSocialProfilesFunctions::render_icon ( $icon, $color, $background, '', false );
|
||||
$html .= "</a>";
|
||||
$html .= "</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '</ul>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
if ( !defined ( 'ABSPATH' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
if (!class_exists('reduxLoadSocialWidget')) {
|
||||
class reduxLoadSocialWidget {
|
||||
public $field_id = '';
|
||||
public $parent = null;
|
||||
|
||||
public function __construct ($parent, $field_id) {
|
||||
$this->parent = $parent;
|
||||
$this->field_id = $field_id;
|
||||
|
||||
|
||||
$this->params = array(
|
||||
'parent' => $this->parent,
|
||||
'field_id' => $this->field_id
|
||||
);
|
||||
|
||||
add_action ( 'widgets_init', array( $this, 'load_widget' ), 0 );
|
||||
}
|
||||
|
||||
function load_widget () {
|
||||
$x = new Extend_WP_Widget_Factory();
|
||||
$x->register('reduxSocialWidgetDisplay', $this->params);
|
||||
}
|
||||
}
|
||||
|
||||
class Extend_WP_Widget_Factory extends WP_Widget_Factory {
|
||||
function register($widget_class, $param = null) {
|
||||
$this->widgets[$widget_class] = new $widget_class($param);
|
||||
}
|
||||
}
|
||||
|
||||
class reduxSocialWidgetDisplay extends WP_Widget {
|
||||
|
||||
public function __construct ($params) {
|
||||
|
||||
extract($params);
|
||||
|
||||
$this->parent = $parent;
|
||||
$this->field_id = $field_id;
|
||||
|
||||
$widget_ops = array(
|
||||
'classname' => 'redux-social-icons-display',
|
||||
'description' => __ ( 'Display social media links', 'ekko' )
|
||||
);
|
||||
|
||||
$control_ops = array(
|
||||
'width' => 250,
|
||||
'height' => 200,
|
||||
'id_base' => 'redux-social-icons-display'
|
||||
); //default width = 250
|
||||
parent::__construct( 'redux-social-icons-display', 'Social Icons', $widget_ops, $control_ops );
|
||||
}
|
||||
|
||||
public function widget ( $args, $instance ) {
|
||||
include_once('class.functions.php');
|
||||
|
||||
extract ( $args, EXTR_SKIP );
|
||||
|
||||
$title = $instance[ 'title' ];
|
||||
$redux_options = get_option($this->parent->args['opt_name']);
|
||||
|
||||
$social_items = $redux_options[$this->field_id];
|
||||
|
||||
echo $before_widget;
|
||||
|
||||
if ( $title ) {
|
||||
echo $before_title . $title . $after_title;
|
||||
}
|
||||
?>
|
||||
<ul class="redux-social-media-list clearfix">
|
||||
<?php
|
||||
if ( is_array ( $social_items ) ) {
|
||||
foreach ( $social_items as $key => $social_item ) {
|
||||
if ( $social_item[ 'enabled' ] ) {
|
||||
$icon = $social_item[ 'icon' ];
|
||||
$color = $social_item[ 'color' ];
|
||||
$background = $social_item[ 'background' ];
|
||||
$base_url = $social_item[ 'url' ];
|
||||
$id = $social_item['id'];
|
||||
|
||||
$url = apply_filters('redux/extensions/social_profiles/' . $this->parent->args['opt_name'] . '/icon_url', $id, $base_url);
|
||||
|
||||
echo "<li>";
|
||||
echo "<a target='_blank' href='" . $base_url . "'>";
|
||||
reduxSocialProfilesFunctions::render_icon ( $icon, $color, $background, '' );
|
||||
echo "</a>";
|
||||
echo "</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
public function update ( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance[ 'title' ] = strip_tags ( $new_instance[ 'title' ] );
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function form ( $instance ) {
|
||||
$defaults = array(
|
||||
'title' => __ ( 'Social', 'ekko' ),
|
||||
);
|
||||
|
||||
$instance = wp_parse_args ( (array) $instance, $defaults );
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id ( "title" ); ?>">
|
||||
<?php _e ( 'Title', 'ekko' ); ?>
|
||||
:
|
||||
<input class="widefat" id="<?php echo $this->get_field_id ( "title" ); ?>" name="<?php echo $this->get_field_name ( "title" ); ?>" type="text" value="<?php echo esc_attr ( $instance[ "title" ] ); ?>" />
|
||||
</label>
|
||||
<label for="redux-social-icons-info">
|
||||
<?php
|
||||
$tab = Redux_Helpers::tabFromField($this->parent, 'social_profiles');
|
||||
$slug = $this->parent->args['page_slug'];
|
||||
|
||||
printf ( __ ( 'Control which icons are displayed and their urls on the %ssettings page%s', 'ekko' ), '<a href="' . admin_url ( 'admin.php?page=' . $slug . '&tab=' . $tab ) . '">', '</a>' );
|
||||
?>
|
||||
</label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
(function( $ ) {
|
||||
"use strict";
|
||||
|
||||
redux.field_objects = redux.field_objects || {};
|
||||
redux.field_objects.social_profiles = redux.field_objects.social_profiles || {};
|
||||
redux.field_objects.social_profiles.fieldID = '';
|
||||
redux.field_objects.social_profiles.optName = '';
|
||||
|
||||
redux.field_objects.social_profiles.init = function( selector ) {
|
||||
if ( !selector ) {
|
||||
selector = $( document ).find( ".redux-group-tab:visible" ).find( '.redux-container-social_profiles:visible' );
|
||||
}
|
||||
|
||||
$( selector ).each(
|
||||
function() {
|
||||
var el = $( this );
|
||||
var parent = el;
|
||||
|
||||
if ( !el.hasClass( 'redux-field-container' ) ) {
|
||||
parent = el.parents( '.redux-field-container:first' );
|
||||
}
|
||||
|
||||
if ( parent.is( ":hidden" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( parent.hasClass( 'redux-field-init' ) ) {
|
||||
parent.removeClass( 'redux-field-init' );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.modInit( el );
|
||||
redux.field_objects.social_profiles.sortListByOrder( el );
|
||||
redux.field_objects.social_profiles.sortEnableListByOrder( el );
|
||||
redux.field_objects.social_profiles.initializeResetButtons( el );
|
||||
redux.field_objects.social_profiles.showEnabledDetails( el );
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.modInit = function( el ) {
|
||||
redux.field_objects.social_profiles.fieldID = el.find( '.redux-social-profiles-container' ).data( 'id' );
|
||||
redux.field_objects.social_profiles.optName = el.find( '.redux-social-profiles-container' ).data( 'opt-name' );
|
||||
;
|
||||
|
||||
// dev_mode
|
||||
var dev_mode = Boolean( el.find( '.redux-social-profiles-container' ).data( 'dev-mode' ) );
|
||||
|
||||
// Add tag to footer, dev mode only.
|
||||
if ( dev_mode === true ) {
|
||||
var ver = el.find( '.redux-social-profiles-container' ).data( 'version' );
|
||||
var dev_html = $( 'div.redux-timer' ).html();
|
||||
|
||||
if ( dev_html !== undefined ) {
|
||||
var pos = dev_html.indexOf( 'Social Profiles' );
|
||||
|
||||
if ( pos === -1 ) {
|
||||
$( 'div.redux-timer' ).html( dev_html + '<br/>Social Profiles extension v.' + ver );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
el.find( '#redux-social-profiles-list' ).sortable(
|
||||
{
|
||||
revert: "invalid",
|
||||
cursor: "move",
|
||||
helper: "clone",
|
||||
handle: ".redux-icon-preview",
|
||||
placeholder: "sortable-placeholder",
|
||||
change: function( event, ui ) {
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
redux.field_objects.social_profiles.reorderSocialItems( el );
|
||||
redux_change( el.find( '.redux-social-profiles-container' ) );
|
||||
},
|
||||
start: function( event, ui ) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '#redux-social-profiles-selector-list' ).sortable(
|
||||
{
|
||||
revert: "invalid",
|
||||
cursor: "move",
|
||||
helper: "clone",
|
||||
placeholder: "sortable-placeholder",
|
||||
change: function( event, ui ) {
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
redux.field_objects.social_profiles.reorderSocialEnable( el );
|
||||
redux_change( el.find( '.redux-social-profiles-container' ) );
|
||||
},
|
||||
start: function( event, ui ) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-social-profiles-url-text' ).on(
|
||||
'blur', function() {
|
||||
var key = $( this ).data( 'key' );
|
||||
var val = $( this ).val();
|
||||
|
||||
redux.field_objects.social_profiles.updateDataString( el, key, 'url', val );
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-social-profiles-item-enable' ).on(
|
||||
'click', function() {
|
||||
var key = $( this ).data( 'key' );
|
||||
redux.field_objects.social_profiles.toggleEnabled( el, key );
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
el.find( '.redux-social-profiles-item-enabled input' ).on(
|
||||
'click', function( e, ui ) {
|
||||
e.preventDefault();
|
||||
|
||||
var item = $( this );
|
||||
var key = item.data( 'key' );
|
||||
|
||||
redux.field_objects.social_profiles.toggleEnabled( el, key );
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.valueFromDataString = function( el, key, name ) {
|
||||
var dataEl = el.find( '.redux-social-profiles-hidden-data-' + key );
|
||||
var rawData = dataEl.val();
|
||||
|
||||
rawData = decodeURIComponent( rawData );
|
||||
rawData = JSON.parse( rawData );
|
||||
|
||||
var theData = rawData[name];
|
||||
|
||||
return theData;
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.updateDataString = function( el, key, name, value ) {
|
||||
var dataEl = el.find( '.redux-social-profiles-hidden-data-' + key );
|
||||
var rawData = dataEl.val();
|
||||
|
||||
rawData = decodeURIComponent( rawData );
|
||||
rawData = JSON.parse( rawData );
|
||||
|
||||
rawData[name] = value;
|
||||
|
||||
rawData = JSON.stringify( rawData );
|
||||
rawData = encodeURIComponent( rawData );
|
||||
|
||||
dataEl.val( rawData );
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.sortListByOrder = function( el ) {
|
||||
var ul = el.find( 'ul#redux-social-profiles-list ' );
|
||||
var li = ul.children( 'li' );
|
||||
|
||||
li.detach().sort(
|
||||
function( a, b ) {
|
||||
return $( a ).find( '.redux-social-profiles-item-order input' ).val() - $( b ).find( '.redux-social-profiles-item-order input' ).val();
|
||||
}
|
||||
);
|
||||
|
||||
ul.append( li );
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.sortEnableListByOrder = function( el ) {
|
||||
var ul = el.find( 'ul#redux-social-profiles-selector-list' );
|
||||
var li = ul.children( 'li' );
|
||||
|
||||
li.detach().sort(
|
||||
function( a, b ) {
|
||||
return $( a ).data( 'order' ) - $( b ).data( 'order' );
|
||||
}
|
||||
);
|
||||
|
||||
ul.append( li );
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.initializeResetButtons = function( el ) {
|
||||
el.find( '.redux-social-profiles-item-reset a' ).click(
|
||||
function() {
|
||||
var buttonClicked = $( this );
|
||||
|
||||
if ( buttonClicked.length > 0 ) {
|
||||
var itemToReset = buttonClicked.data( 'value' );
|
||||
|
||||
redux.field_objects.social_profiles.resetItem( el, itemToReset );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.resetItem = function( el, itemID ) {
|
||||
var defaultTextColor = reduxSocialDefaults[itemID]['color'];
|
||||
var defaultBackgroundColor = reduxSocialDefaults[itemID]['background'];
|
||||
|
||||
el.find( '.redux-social-profiles-color-picker-' + itemID + '.text' ).spectrum( "set", defaultTextColor );
|
||||
el.find( '.redux-social-profiles-color-picker-' + itemID + '.background' ).spectrum(
|
||||
"set", defaultBackgroundColor
|
||||
);
|
||||
|
||||
redux.field_objects.social_profiles.updateDataString( el, itemID, 'color', defaultTextColor );
|
||||
redux.field_objects.social_profiles.updateDataString( el, itemID, 'background', defaultBackgroundColor );
|
||||
|
||||
redux.field_objects.social_profiles.updatePreview( el, itemID );
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.updatePreview = function( el, itemID ) {
|
||||
var textColorInput = redux.field_objects.social_profiles.valueFromDataString( el, itemID, 'color' );
|
||||
var backgroundColorInput = redux.field_objects.social_profiles.valueFromDataString( el, itemID, 'background' );
|
||||
|
||||
var icon = reduxSocialDefaults[itemID]['icon'];
|
||||
var symbol = el.find( '#redux-social-item-' + itemID + ' i.' + icon );
|
||||
|
||||
symbol.css( 'background-color', backgroundColorInput );
|
||||
symbol.css( 'color', textColorInput );
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.toggleEnabled = function( el, itemID ) {
|
||||
var itemEnable = el.find( '#redux-social-profiles-item-enable-' + itemID );
|
||||
var enabled = itemEnable.hasClass( 'enabled' );
|
||||
|
||||
var enabledBool;
|
||||
if ( enabled ) {
|
||||
itemEnable.removeClass( 'enabled' );
|
||||
enabledBool = false;
|
||||
} else {
|
||||
itemEnable.addClass( 'enabled' );
|
||||
enabledBool = true;
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.updateDataString( el, itemID, 'enabled', enabledBool );
|
||||
|
||||
redux_change( el.find( '.redux-social-profiles-container' ) );
|
||||
|
||||
redux.field_objects.social_profiles.showEnabledDetails( el );
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.showEnabledDetails = function( el ) {
|
||||
var socialItems = el.find( 'li.redux-social-profiles-item-enable' );
|
||||
|
||||
if ( socialItems.length > 0 ) {
|
||||
|
||||
var palette = [
|
||||
["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff"],
|
||||
["#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff"],
|
||||
["#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d9ead3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc"],
|
||||
["#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
|
||||
["#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0"],
|
||||
["#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79"],
|
||||
["#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"],
|
||||
["#5b0f00", "#660000", "#783f04", "#7f6000", "#274e13", "#0c343d", "#1c4587", "#073763", "#20124d", "#4c1130"]
|
||||
];
|
||||
|
||||
socialItems.each(
|
||||
function( index ) {
|
||||
var item = $( this );
|
||||
var key = item.data( 'key' );
|
||||
|
||||
if ( item.hasClass( 'enabled' ) ) {
|
||||
|
||||
el.find( '.redux-social-profiles-color-picker-' + key ).spectrum(
|
||||
{
|
||||
showAlpha: true,
|
||||
showInput: true,
|
||||
allowEmpty: true,
|
||||
className: 'redux-full-spectrum',
|
||||
showInitial: true,
|
||||
showPalette: true,
|
||||
showSelectionPalette: true,
|
||||
clickoutFiresChange: true,
|
||||
preferredFormat: 'rgb',
|
||||
localStorageKey: 'redux.social-profiles.spectrum',
|
||||
palette: palette,
|
||||
change: function( color ) {
|
||||
var className;
|
||||
|
||||
if ( $( this ).hasClass( 'text' ) ) {
|
||||
className = 'color';
|
||||
} else {
|
||||
className = 'background';
|
||||
}
|
||||
|
||||
console.log(color);
|
||||
if (color === null) {
|
||||
color = '';
|
||||
} else {
|
||||
color = color.toRgbString();
|
||||
}
|
||||
|
||||
redux.field_objects.social_profiles.updateDataString(
|
||||
el, key, className, color
|
||||
);
|
||||
|
||||
redux.field_objects.social_profiles.updatePreview( el, key );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
el.find( 'li#redux-social-item-' + key ).slideDown();
|
||||
|
||||
var enabledInput = el.find( 'input.checkbox-' + key );
|
||||
var hidden = $( enabledInput ).parent().find( '.checkbox-check-' + key );
|
||||
|
||||
enabledInput.prop( 'checked', true );
|
||||
hidden.val( 1 );
|
||||
} else {
|
||||
var item = el.find( 'li#redux-social-item-' + key );
|
||||
|
||||
if ( item.is( ':hidden' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
item.slideUp('medium');
|
||||
|
||||
var enabledInput = el.find( 'input.checkbox-' + key );
|
||||
var hidden = $( enabledInput ).parent().find( '.checkbox-check-' + key );
|
||||
|
||||
enabledInput.prop( 'checked', false );
|
||||
hidden.val( 0 );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.reorderSocialItems = function( el ) {
|
||||
var socialItems = el.find( 'ul#redux-social-profiles-list li' );
|
||||
|
||||
if ( socialItems.length > 0 ) {
|
||||
socialItems.each(
|
||||
function( index ) {
|
||||
var item = $( this );
|
||||
var key = item.data( 'key' );
|
||||
var orderInput = item.find( '.redux-social-profiles-item-order input' );
|
||||
|
||||
orderInput.val( index );
|
||||
redux.field_objects.social_profiles.updateDataString( el, key, 'order', index );
|
||||
|
||||
el.find( '#redux-social-profiles-item-enable-' + key ).data( 'order', index );
|
||||
}
|
||||
);
|
||||
|
||||
redux.field_objects.social_profiles.sortEnableListByOrder( el );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
redux.field_objects.social_profiles.reorderSocialEnable = function( el ) {
|
||||
var socialItems = el.find( 'ul#redux-social-profiles-selector-list li' );
|
||||
|
||||
if ( socialItems.length > 0 ) {
|
||||
socialItems.each(
|
||||
function( index ) {
|
||||
var item = $( this );
|
||||
var key = item.data( 'key' );
|
||||
|
||||
item.data( 'order', index );
|
||||
|
||||
var control = el.find( 'li#redux-social-item-' + key );
|
||||
var orderInput = control.find( '.redux-social-profiles-item-order input' );
|
||||
//var orderInput = redux.field_objects.social_profiles.valueFromDataString(el, key, 'order');
|
||||
|
||||
orderInput.val( index );
|
||||
redux.field_objects.social_profiles.updateDataString( el, key, 'order', index );
|
||||
}
|
||||
);
|
||||
}
|
||||
;
|
||||
|
||||
redux.field_objects.social_profiles.sortListByOrder( el );
|
||||
};
|
||||
})( jQuery );
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user