first commit
This commit is contained in:
+324
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* The admin-specific functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Admin
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the module.
|
||||
*/
|
||||
class Powerkit_Social_Links_Admin extends Powerkit_Module_Admin {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_reset_cache', array( $this, 'register_reset_cache' ) );
|
||||
add_filter( 'powerkit_ajax_reset_cache', array( $this, 'register_reset_cache' ) );
|
||||
add_filter( 'user_contactmethods', array( $this, 'contactmethods' ), 1000, 1 );
|
||||
add_filter( 'coauthors_guest_author_fields', array( $this, 'guest_author_fields' ), 10, 2 );
|
||||
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Reset Cache
|
||||
*
|
||||
* @param array $list Change list reset cache.
|
||||
*/
|
||||
public function register_reset_cache( $list ) {
|
||||
$slug = powerkit_get_page_slug( $this->slug );
|
||||
|
||||
$list[ $slug ] = 'powerkit_social_links_counter';
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom user contact methods
|
||||
*
|
||||
* @param array $user_contacts array of all user contacts.
|
||||
*/
|
||||
public function contactmethods( $user_contacts ) {
|
||||
return array_merge( $user_contacts, powerkit_get_author_fields() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Social Links fields in Guest Author profiles
|
||||
*
|
||||
* @param array $fields Fields to be returned.
|
||||
* @param array $groups Field groups.
|
||||
*/
|
||||
public function guest_author_fields( $fields, $groups ) {
|
||||
if ( in_array( 'all', $groups, true ) || in_array( 'contact-info', $groups, true ) ) {
|
||||
foreach ( powerkit_get_author_fields() as $slug => $name ) {
|
||||
$fields[] = array(
|
||||
'key' => $slug,
|
||||
'label' => $name,
|
||||
'group' => 'contact-info',
|
||||
);
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_options_page() {
|
||||
add_options_page( esc_html__( 'Social Links', 'powerkit' ), esc_html__( 'Social Links', 'powerkit' ), 'manage_options', powerkit_get_page_slug( $this->slug ), array( $this, 'build_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build admin page
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function build_options_page() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'powerkit' ) );
|
||||
}
|
||||
|
||||
$this->save_options_page();
|
||||
?>
|
||||
<div class="wrap pk-social-links-wrap">
|
||||
<h1><?php esc_html_e( 'Social Links', 'powerkit' ); ?></h1>
|
||||
|
||||
<div class="pk-social-links-settings">
|
||||
<?php $social_social_links = apply_filters( 'powerkit_social_links_list', array() ); ?>
|
||||
<form class="pk-social-links-basic" method="post">
|
||||
<div class="pk-social-links-tabs">
|
||||
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
|
||||
<a class="nav-tab nav-tab-active general" href="#tab-general"><?php esc_html_e( 'General', 'powerkit' ); ?></a>
|
||||
|
||||
<?php foreach ( $social_social_links as $item ) { ?>
|
||||
<a class="nav-tab <?php echo esc_attr( $item['id'] ); ?>" href="#tab-<?php echo esc_attr( $item['id'] ); ?>"><?php echo esc_html( $item['name'] ); ?></a>
|
||||
<?php } ?>
|
||||
</nav>
|
||||
|
||||
<div id="tab-general" class="tab-wrap tab-active">
|
||||
<h2><?php esc_html_e( 'General Settings', 'powerkit' ); ?></h2>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<!-- Social Links -->
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Social Links', 'powerkit' ); ?></label></th>
|
||||
<td>
|
||||
<div class="pk-social-links-source">
|
||||
<?php
|
||||
$links = $social_social_links;
|
||||
|
||||
if ( $links ) {
|
||||
foreach ( $links as $key => $link ) {
|
||||
$powerkit_social_links_multiple_list = get_option( 'powerkit_social_links_multiple_list', array() );
|
||||
|
||||
$checked = in_array( $key, $powerkit_social_links_multiple_list, true ) ? 'checked' : '';
|
||||
?>
|
||||
<p class="social-item"><label for="powerkit_social_links_multiple_list_<?php echo esc_attr( $key ); ?>"><input class="powerkit_social_links_multiple_list" data-item="<?php echo esc_attr( $key ); ?>" id="powerkit_social_links_multiple_list_<?php echo esc_attr( $key ); ?>" name="powerkit_social_links_multiple_list[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" <?php echo esc_attr( $checked ); ?>> <?php echo esc_attr( $link['name'] ); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Order -->
|
||||
<tr>
|
||||
<th scope="row"><label for="powerkit_social_links_order_multiple_list"><?php esc_html_e( 'Order', 'powerkit' ); ?></label></th>
|
||||
<td>
|
||||
<ul class="social-sortable">
|
||||
<?php
|
||||
$social_links_save = get_option( 'powerkit_social_links_order_multiple_list', array() );
|
||||
|
||||
$links = $social_social_links;
|
||||
|
||||
// Sort.
|
||||
if ( $social_links_save && $links ) {
|
||||
$social_links_save = array_flip( $social_links_save );
|
||||
$links = array_merge( $social_links_save, $links );
|
||||
}
|
||||
|
||||
// Output.
|
||||
if ( $links ) {
|
||||
foreach ( $links as $key => $link ) {
|
||||
?>
|
||||
<li class="ui-state-default <?php echo esc_attr( $key ); ?>">
|
||||
<span class="dashicons dashicons-leftright"></span>
|
||||
<input type="text" name="powerkit_social_links_order_multiple_list[]" value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $link['name'] ); ?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Link Target -->
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Link Target', 'powerkit' ); ?></th>
|
||||
<td>
|
||||
<p><label><input class="tog" id="powerkit_social_links_link_target_same" name="powerkit_social_links_link_target" type="radio" value="same" <?php checked( get_option( 'powerkit_social_links_link_target', 'new' ), 'same' ); ?>> <?php esc_html_e( 'Open in same window', 'powerkit' ); ?></label></p>
|
||||
<p><label><input class="tog" id="powerkit_social_links_link_target_new" name="powerkit_social_links_link_target" type="radio" value="new" <?php checked( get_option( 'powerkit_social_links_link_target', 'new' ), 'new' ); ?>> <?php esc_html_e( 'Open in new window/tab', 'powerkit' ); ?></label></p>
|
||||
</td>
|
||||
</tr>
|
||||
<p></p>
|
||||
<!-- Apply "nofollow" attribute -->
|
||||
<tr>
|
||||
<th scope="row"><label class="title" for="powerkit_social_links_nofollow"><?php esc_html_e( 'Apply "nofollow" attribute', 'powerkit' ); ?></label></th>
|
||||
<td><input id="powerkit_social_links_nofollow" name="powerkit_social_links_nofollow" type="checkbox" value="true" <?php checked( (bool) get_option( 'powerkit_social_links_nofollow', true ) ); ?>></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php foreach ( $social_social_links as $item ) { ?>
|
||||
<div id="tab-<?php echo esc_attr( $item['id'] ); ?>" class="tab-wrap">
|
||||
<h2><?php echo esc_attr( powerkit_social_links_specific_param( $item['id'], 'name' ) ); ?> <?php esc_html_e( 'Settings', 'powerkit' ); ?></h2>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<!-- Title -->
|
||||
<tr>
|
||||
<th scope="row"><label for="powerkit_social_links_title_<?php echo esc_attr( $item['id'] ); ?>"><?php esc_html_e( 'Title', 'powerkit' ); ?></label></th>
|
||||
<td><input class="regular-text" id="powerkit_social_links_title_<?php echo esc_attr( $item['id'] ); ?>" name="powerkit_social_links_title_<?php echo esc_attr( $item['id'] ); ?>" type="text" value="<?php echo esc_attr( get_option( 'powerkit_social_links_title_' . $item['id'], powerkit_social_links_specific_param( $item['id'], 'name' ) ) ); ?>" /></td>
|
||||
</tr>
|
||||
<!-- Label -->
|
||||
<?php if ( 'counter' === powerkit_social_links_specific_param( $item['id'], 'mode' ) ) { ?>
|
||||
<tr>
|
||||
<th scope="row"><label for="powerkit_social_links_label_<?php echo esc_attr( $item['id'] ); ?>"><?php esc_html_e( 'Label', 'powerkit' ); ?></label></th>
|
||||
<td><input class="regular-text" id="powerkit_social_links_label_<?php echo esc_attr( $item['id'] ); ?>" name="powerkit_social_links_label_<?php echo esc_attr( $item['id'] ); ?>" type="text" value="<?php echo esc_attr( get_option( 'powerkit_social_links_label_' . $item['id'], powerkit_social_links_specific_param( $item['id'], 'label' ) ) ); ?>" /></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<!-- Render Fields -->
|
||||
<?php
|
||||
if ( isset( $item['fields'] ) && $item['fields'] ) {
|
||||
foreach ( $item['fields'] as $field_key => $field_caption ) {
|
||||
if ( is_array( $field_caption ) ) {
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><label class="title" for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses( $field_caption['title'], 'post' ); ?></label></th>
|
||||
<td>
|
||||
<select class="regular-text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>">
|
||||
<?php foreach ( $field_caption['options'] as $key => $val ) { ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, get_option( $field_key ) ); ?>><?php echo esc_attr( $val ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><label class="title" for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses( $field_caption, 'post' ); ?></label></th>
|
||||
<td><input class="regular-text" id="<?php echo esc_attr( $field_key ); ?>" name="<?php echo esc_attr( $field_key ); ?>" type="text" value="<?php echo esc_attr( get_option( $field_key ) ); ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php wp_nonce_field(); ?>
|
||||
|
||||
<p class="submit">
|
||||
<input class="button button-primary" name="save_settings" type="submit" value="<?php esc_html_e( 'Save changes', 'powerkit' ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings save
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected function save_options_page() {
|
||||
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
|
||||
|
||||
if ( isset( $_POST['powerkit_social_links_multiple_list'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_social_links_multiple_list', array_map( 'sanitize_key', (array) $_POST['powerkit_social_links_multiple_list'] ) ); // Input var ok; sanitization ok.
|
||||
} else {
|
||||
update_option( 'powerkit_social_links_multiple_list', array() );
|
||||
}
|
||||
if ( isset( $_POST['powerkit_social_links_order_multiple_list'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_social_links_order_multiple_list', array_map( 'sanitize_key', (array) $_POST['powerkit_social_links_order_multiple_list'] ) ); // Input var ok; sanitization ok.
|
||||
} else {
|
||||
update_option( 'powerkit_social_links_order_multiple_list', array() );
|
||||
}
|
||||
if ( isset( $_POST['powerkit_social_links_link_target'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_social_links_link_target', sanitize_text_field( wp_unslash( $_POST['powerkit_social_links_link_target'] ) ) ); // Input var ok.
|
||||
}
|
||||
if ( isset( $_POST['powerkit_social_links_nofollow'] ) ) { // Input var ok.
|
||||
update_option( 'powerkit_social_links_nofollow', true );
|
||||
} else {
|
||||
update_option( 'powerkit_social_links_nofollow', false );
|
||||
}
|
||||
|
||||
// Save social params.
|
||||
$social_social_links = apply_filters( 'powerkit_social_links_list', array() );
|
||||
|
||||
foreach ( $social_social_links as $item ) {
|
||||
$id = $item['id'];
|
||||
|
||||
if ( isset( $_POST[ "powerkit_social_links_title_{$id}" ] ) ) { // Input var ok.
|
||||
update_option( "powerkit_social_links_title_{$id}", sanitize_text_field( wp_unslash( $_POST[ "powerkit_social_links_title_{$id}" ] ) ) ); // Input var ok.
|
||||
}
|
||||
|
||||
if ( isset( $_POST[ "powerkit_social_links_label_{$id}" ] ) ) { // Input var ok.
|
||||
|
||||
if ( 'counter' === powerkit_social_links_specific_param( $id, 'mode' ) ) {
|
||||
update_option( "powerkit_social_links_label_{$id}", sanitize_text_field( wp_unslash( $_POST[ "powerkit_social_links_label_{$id}" ] ) ) ); // Input var ok.
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $item['fields'] ) && $item['fields'] ) {
|
||||
foreach ( $item['fields'] as $field_key => $field_caption ) {
|
||||
if ( isset( $_POST[ $field_key ] ) ) { // Input var ok.
|
||||
update_option( $field_key, sanitize_text_field( wp_unslash( $_POST[ $field_key ] ) ) ); // Input var ok.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset cache.
|
||||
Powerkit_Connect::reset_cache( 'powerkit_social_links_counter' );
|
||||
|
||||
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets and JavaScript for the admin area.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
if ( 'settings_page_' . powerkit_get_page_slug( $this->slug ) === $page ) {
|
||||
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-social-links', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/admin-powerkit-social-links.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'powerkit-social-links', plugin_dir_url( __FILE__ ) . 'js/admin-powerkit-social-links.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
.pk-social-links-wrap .nav-tab:not(.general) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-tabs .tab-wrap {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-tabs .tab-wrap.tab-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subsubsub {
|
||||
margin: 15px -2px 8px 0;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap.subtab-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap h2 {
|
||||
margin-bottom: 38px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li {
|
||||
position: relative;
|
||||
border: 1px solid #CCCCCC;
|
||||
background: #E5E5E5;
|
||||
display: none;
|
||||
border: none;
|
||||
margin: 0 3px 5px 3px;
|
||||
padding: 8px 18px;
|
||||
font-size: 14px;
|
||||
line-height: 1.2em;
|
||||
min-width: 200px;
|
||||
height: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li.ui-state-highlight {
|
||||
display: block;
|
||||
border: 1px dashed #CCCCCC;
|
||||
background: #E5E5E5;
|
||||
padding: 8px 18px;
|
||||
line-height: 1.2em;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li span {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.pk-social-links-source {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-social-links-source .social-item {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.pk-social-links-source:after {
|
||||
display: table;
|
||||
clear: both;
|
||||
content: '';
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
.pk-social-links-wrap .nav-tab:not(.general) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-tabs .tab-wrap {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-tabs .tab-wrap.tab-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subsubsub {
|
||||
margin: 15px 0 8px -2px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap.subtab-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .pk-social-links-subtabs .subtab-wrap h2 {
|
||||
margin-bottom: 38px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li {
|
||||
position: relative;
|
||||
border: 1px solid #CCCCCC;
|
||||
background: #E5E5E5;
|
||||
display: none;
|
||||
border: none;
|
||||
margin: 0 3px 5px 3px;
|
||||
padding: 8px 18px;
|
||||
font-size: 14px;
|
||||
line-height: 1.2em;
|
||||
min-width: 200px;
|
||||
height: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li.ui-state-highlight {
|
||||
display: block;
|
||||
border: 1px dashed #CCCCCC;
|
||||
background: #E5E5E5;
|
||||
padding: 8px 18px;
|
||||
line-height: 1.2em;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li span {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pk-social-links-wrap .social-sortable li:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.pk-social-links-source {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pk-social-links-source .social-item {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.pk-social-links-source:after {
|
||||
display: table;
|
||||
clear: both;
|
||||
content: '';
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
( function( $ ) {
|
||||
|
||||
/*
|
||||
* Social Links
|
||||
*/
|
||||
$( function() {
|
||||
/*
|
||||
* Tabs
|
||||
*/
|
||||
$( '.pk-social-links-wrap .pk-social-links-tabs .nav-tab-wrapper .nav-tab' ).on( 'click', function( event ) {
|
||||
|
||||
$( '.pk-social-links-wrap .pk-social-links-tabs .nav-tab-wrapper .nav-tab' ).removeClass( 'nav-tab-active' );
|
||||
|
||||
$( this ).addClass( 'nav-tab-active' );
|
||||
|
||||
// Container
|
||||
$( '.pk-social-links-wrap .pk-social-links-tabs .tab-wrap' ).removeClass( 'tab-active' );
|
||||
|
||||
$( $( this ).attr( 'href' ) ).addClass( 'tab-active' );
|
||||
|
||||
$( window ).resize();
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
/*
|
||||
* jQuery Sortable UI
|
||||
*/
|
||||
$( '.pk-social-links-wrap .form-table .social-sortable' ).sortable({
|
||||
placeholder: 'ui-state-highlight',
|
||||
} );
|
||||
|
||||
$( '.pk-social-links-wrap .form-table .social-sortable' ).disableSelection();
|
||||
|
||||
/*
|
||||
* Check display fields
|
||||
*/
|
||||
function powerkitSLinksCheckDisplayFields() {
|
||||
$( '.pk-social-links-wrap .powerkit_social_links_multiple_list' ).each( function( index, el ) {
|
||||
|
||||
var item = $( el ).attr( 'data-item' );
|
||||
|
||||
if ( !$( el ).prop( 'checked' ) ) {
|
||||
$( '.pk-social-links-wrap .nav-tab.' + item ).hide();
|
||||
|
||||
$( '.pk-social-links-wrap .social-sortable .ui-state-default.' + item ).hide();
|
||||
} else {
|
||||
$( '.pk-social-links-wrap .nav-tab.' + item ).show();
|
||||
|
||||
$( '.pk-social-links-wrap .social-sortable .ui-state-default.' + item ).show();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
/*
|
||||
* Cick display social
|
||||
*/
|
||||
$( '.pk-social-links-wrap .powerkit_social_links_multiple_list' ).on( 'click', function( event ) {
|
||||
powerkitSLinksCheckDisplayFields();
|
||||
} );
|
||||
|
||||
/*
|
||||
* INIT
|
||||
*/
|
||||
powerkitSLinksCheckDisplayFields();
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Social Links
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules
|
||||
*/
|
||||
|
||||
if ( class_exists( 'Powerkit_Module' ) ) {
|
||||
/**
|
||||
* Init module
|
||||
*/
|
||||
class Powerkit_Social_Links extends Powerkit_Module {
|
||||
|
||||
/**
|
||||
* Register module
|
||||
*/
|
||||
public function register() {
|
||||
$this->name = esc_html__( 'Social Links', 'powerkit' );
|
||||
$this->desc = esc_html__( 'Display a list of links to your social accounts with beautiful icons and followers’ counts in pre-defined theme locations, sidebar widget or post content via shortcode. Add social links for post authors with the help of the new user contact fields.', 'powerkit' );
|
||||
$this->slug = 'social_links';
|
||||
$this->type = 'default';
|
||||
$this->category = 'social';
|
||||
$this->priority = 20;
|
||||
$this->public = true;
|
||||
$this->enabled = true;
|
||||
$this->load_extensions = array(
|
||||
'connect',
|
||||
);
|
||||
|
||||
$this->links = array(
|
||||
array(
|
||||
'name' => esc_html__( 'Go to settings', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( $this->slug ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'Connect', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( 'connect' ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'Clear cache', 'powerkit' ),
|
||||
'url' => powerkit_get_page_url( $this->slug . '&action=powerkit_reset_cache' ),
|
||||
),
|
||||
array(
|
||||
'name' => esc_html__( 'View documentation', 'powerkit' ),
|
||||
'url' => powerkit_get_setting( 'documentation' ) . '/social-integrations/social-links/',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize module
|
||||
*/
|
||||
public function initialize() {
|
||||
|
||||
/* Load the required dependencies for this module */
|
||||
|
||||
// Helpers Functions for the module.
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-links.php';
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-links-connect-list.php';
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-links-list.php';
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-links-api-config.php';
|
||||
require_once dirname( __FILE__ ) . '/helpers/helper-powerkit-links-api.php';
|
||||
|
||||
// The classes responsible for defining all actions.
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-social-links-shortcode.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-social-links-widget.php';
|
||||
|
||||
if ( function_exists( 'register_block_type' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-social-links-block.php';
|
||||
}
|
||||
|
||||
// Admin and public area.
|
||||
require_once dirname( __FILE__ ) . '/admin/class-powerkit-social-links-admin.php';
|
||||
require_once dirname( __FILE__ ) . '/public/class-powerkit-social-links-public.php';
|
||||
|
||||
new Powerkit_Social_Links_Admin( $this->slug );
|
||||
new Powerkit_Social_Links_Public( $this->slug );
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Social_Links();
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Social API Config
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Social API Config Class
|
||||
*/
|
||||
class Powerkit_Links_Api_Config {
|
||||
|
||||
/**
|
||||
* Cache Timeout
|
||||
*
|
||||
* @var string $cache_timeout Cache Timeout.
|
||||
*/
|
||||
public static $cache_timeout;
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* @var string $config Config List.
|
||||
*/
|
||||
public static $config = array();
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
self::$cache_timeout = (int) apply_filters( 'powerkit_social_links_cache_timeout', 60 );
|
||||
|
||||
self::$config['dribbble_user'] = get_option( 'powerkit_social_links_dribbble_user' );
|
||||
self::$config['facebook_user'] = get_option( 'powerkit_social_links_facebook_user' );
|
||||
self::$config['instagram_user'] = get_option( 'powerkit_social_links_instagram_user' );
|
||||
self::$config['youtube_slug'] = get_option( 'powerkit_social_links_youtube_slug' );
|
||||
self::$config['youtube_channel_type'] = get_option( 'powerkit_social_links_youtube_channel_type' );
|
||||
self::$config['telegram_chat'] = get_option( 'powerkit_social_links_telegram_chat' );
|
||||
self::$config['pinterest_user'] = get_option( 'powerkit_social_links_pinterest_user' );
|
||||
self::$config['soundcloud_user_id'] = get_option( 'powerkit_social_links_soundcloud_user_id' );
|
||||
self::$config['vimeo_user'] = get_option( 'powerkit_social_links_vimeo_user' );
|
||||
self::$config['twitter_user'] = get_option( 'powerkit_social_links_twitter_user' );
|
||||
self::$config['behance_user'] = get_option( 'powerkit_social_links_behance_user' );
|
||||
self::$config['github_user'] = get_option( 'powerkit_social_links_github_user' );
|
||||
self::$config['vk_id'] = get_option( 'powerkit_social_links_vk_id' );
|
||||
self::$config['vk_type'] = get_option( 'powerkit_social_links_vk_type' );
|
||||
self::$config['twitch_user_id'] = get_option( 'powerkit_social_links_twitch_user_id' );
|
||||
self::$config['flickr_user_id'] = get_option( 'powerkit_social_links_flickr_user_id' );
|
||||
self::$config['snapchat_user'] = get_option( 'powerkit_social_links_snapchat_user' );
|
||||
self::$config['medium_user'] = get_option( 'powerkit_social_links_medium_user' );
|
||||
self::$config['reddit_user'] = get_option( 'powerkit_social_links_reddit_user' );
|
||||
self::$config['reddit_type'] = get_option( 'powerkit_social_links_reddit_type' );
|
||||
self::$config['strava_user'] = get_option( 'powerkit_social_links_strava_user' );
|
||||
self::$config['ok_slug'] = get_option( 'powerkit_social_links_ok_slug' );
|
||||
self::$config['ok_type'] = get_option( 'powerkit_social_links_ok_type' );
|
||||
self::$config['linkedin_slug'] = get_option( 'powerkit_social_links_linkedin_slug' );
|
||||
}
|
||||
}
|
||||
+1428
File diff suppressed because it is too large
Load Diff
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Register Connect List
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add all items to list
|
||||
*
|
||||
* @param array $list Array social list.
|
||||
*/
|
||||
function powerkit_connect_total( $list = array() ) {
|
||||
|
||||
// Facebook.
|
||||
$list['facebook'] = array(
|
||||
'id' => 'facebook',
|
||||
'name' => esc_html__( 'Facebook', 'powerkit' ),
|
||||
);
|
||||
|
||||
// Instagram.
|
||||
$list['instagram'] = array(
|
||||
'id' => 'instagram',
|
||||
'name' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
);
|
||||
|
||||
// Twitter.
|
||||
$list['twitter'] = array(
|
||||
'id' => 'twitter',
|
||||
'name' => esc_html__( 'Twitter', 'powerkit' ),
|
||||
);
|
||||
|
||||
return $list;
|
||||
}
|
||||
add_filter( 'powerkit_register_connect_list', 'powerkit_connect_total' );
|
||||
+812
@@ -0,0 +1,812 @@
|
||||
<?php
|
||||
/**
|
||||
* Register Social Links List
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set list social
|
||||
*
|
||||
* @param array $list Array social params.
|
||||
* @return array Array social params.
|
||||
*/
|
||||
function powerkit_social_links_list( $list = array() ) {
|
||||
|
||||
// Facebook.
|
||||
$list['facebook'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'facebook',
|
||||
'name' => esc_html__( 'Facebook', 'powerkit' ),
|
||||
'label' => esc_html__( 'Likes', 'powerkit' ),
|
||||
'link' => esc_url( 'https://facebook.com/%powerkit_social_links_facebook_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_facebook_user' => esc_html__( 'Facebook User', 'powerkit' ),
|
||||
'powerkit_social_links_facebook_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Twitter.
|
||||
$list['twitter'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'twitter',
|
||||
'name' => esc_html__( 'Twitter', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://twitter.com/%powerkit_social_links_twitter_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_twitter_user' => esc_html__( 'Twitter User', 'powerkit' ),
|
||||
'powerkit_social_links_twitter_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Instagram.
|
||||
$list['instagram'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'instagram',
|
||||
'name' => esc_html__( 'Instagram', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://www.instagram.com/%powerkit_social_links_instagram_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_instagram_user' => esc_html__( 'Instagram User', 'powerkit' ),
|
||||
'powerkit_social_links_instagram_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Pinterest.
|
||||
$list['pinterest'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'pinterest',
|
||||
'name' => esc_html__( 'Pinterest', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
'link' => esc_url( 'https://pinterest.com/%powerkit_social_links_pinterest_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_pinterest_user' => esc_html__( 'Pinterest User', 'powerkit' ),
|
||||
'powerkit_social_links_pinterest_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// YouTube.
|
||||
$list['youtube'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'youtube',
|
||||
'name' => esc_html__( 'YouTube', 'powerkit' ),
|
||||
'label' => esc_html__( 'Subscribers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_youtube_channel_type' => array(
|
||||
'user' => esc_url( 'https://www.youtube.com/user/%powerkit_social_links_youtube_slug%' ),
|
||||
'channel' => esc_url( 'https://www.youtube.com/channel/%powerkit_social_links_youtube_slug%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_youtube_channel_type' => array(
|
||||
'title' => esc_html__( 'YouTube Channel Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'user' => esc_html__( 'User', 'powerkit' ),
|
||||
'channel' => esc_html__( 'Channel', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_youtube_slug' => esc_html__( 'YouTube User or Channel ID', 'powerkit' ),
|
||||
'powerkit_social_links_youtube_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Telegram.
|
||||
$list['telegram'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'telegram',
|
||||
'name' => esc_html__( 'Telegram', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => 'https://t.me/%powerkit_social_links_telegram_chat%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_telegram_chat' => esc_html__( 'Telegram Channel ID', 'powerkit' ),
|
||||
'powerkit_social_links_telegram_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Vimeo.
|
||||
$list['vimeo'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'vimeo',
|
||||
'name' => esc_html__( 'Vimeo', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://vimeo.com/%powerkit_social_links_vimeo_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_vimeo_user' => esc_html__( 'Vimeo User ID', 'powerkit' ),
|
||||
'powerkit_social_links_vimeo_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// SoundCloud.
|
||||
$list['soundcloud'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'soundcloud',
|
||||
'name' => esc_html__( 'SoundCloud', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://soundcloud.com/%powerkit_social_links_soundcloud_user_id%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_soundcloud_user_id' => esc_html__( 'SoundCloud User ID', 'powerkit' ),
|
||||
'powerkit_social_links_soundcloud_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Spotify.
|
||||
$list['spotify'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'spotify',
|
||||
'name' => esc_html__( 'Spotify', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_spotify_type' => array(
|
||||
'user' => esc_url( 'https://open.spotify.com/user/%powerkit_social_links_spotify_user%' ),
|
||||
'show' => esc_url( 'https://open.spotify.com/show/%powerkit_social_links_spotify_user%' ),
|
||||
'artist' => esc_url( 'https://open.spotify.com/artist/%powerkit_social_links_spotify_user%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_spotify_type' => array(
|
||||
'title' => esc_html__( 'Spotify Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'user' => esc_html__( 'User', 'powerkit' ),
|
||||
'show' => esc_html__( 'Show', 'powerkit' ),
|
||||
'artist' => esc_html__( 'Artist', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_spotify_user' => esc_html__( 'Spotify User or Show ID', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Dribbble.
|
||||
$list['dribbble'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'dribbble',
|
||||
'name' => esc_html__( 'Dribbble', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://dribbble.com/%powerkit_social_links_dribbble_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_dribbble_user' => esc_html__( 'Dribbble User ID', 'powerkit' ),
|
||||
'powerkit_social_links_dribbble_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Behance.
|
||||
$list['behance'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'behance',
|
||||
'name' => esc_html__( 'Behance', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://www.behance.net/%powerkit_social_links_behance_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_behance_user' => esc_html__( 'Behance User ID', 'powerkit' ),
|
||||
'powerkit_social_links_behance_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// GitHub.
|
||||
$list['github'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'github',
|
||||
'name' => esc_html__( 'GitHub', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://github.com/%powerkit_social_links_github_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_github_user' => esc_html__( 'GitHub User ID', 'powerkit' ),
|
||||
'powerkit_social_links_github_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Odnoklassniki.
|
||||
$list['ok'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'ok',
|
||||
'name' => esc_html__( 'Odnoklassniki', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_ok_type' => array(
|
||||
'profile' => esc_url( 'https://ok.ru/profile/%powerkit_social_links_ok_slug%' ),
|
||||
'profile_name' => esc_url( 'https://ok.ru/%powerkit_social_links_ok_slug%' ),
|
||||
'group' => esc_url( 'https://ok.ru/group/%powerkit_social_links_ok_slug%' ),
|
||||
'group_name' => esc_url( 'https://ok.ru/%powerkit_social_links_ok_slug%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_ok_type' => array(
|
||||
'title' => esc_html__( 'Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'profile' => esc_html__( 'Profile ID', 'powerkit' ),
|
||||
'profile_name' => esc_html__( 'Profile Name', 'powerkit' ),
|
||||
'group' => esc_html__( 'Group ID', 'powerkit' ),
|
||||
'group_name' => esc_html__( 'Group Name', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_ok_slug' => esc_html__( 'Odnoklassniki Slug / ID', 'powerkit' ),
|
||||
'powerkit_social_links_ok_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// VK.
|
||||
$list['vk'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'vk',
|
||||
'name' => esc_html__( 'VK', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_vk_type' => array(
|
||||
'group' => esc_url( 'https://vk.com/%powerkit_social_links_vk_id%' ),
|
||||
'user' => esc_url( 'https://vk.com/%powerkit_social_links_vk_id%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_vk_type' => array(
|
||||
'title' => esc_html__( 'Profile Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'group' => esc_html__( 'Group', 'powerkit' ),
|
||||
'user' => esc_html__( 'User', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_vk_id' => esc_html__( 'Group or User ID', 'powerkit' ),
|
||||
'powerkit_social_links_vk_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Xing.
|
||||
$list['xing'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'xing',
|
||||
'name' => esc_html__( 'Xing', 'powerkit' ),
|
||||
'label' => esc_html__( 'Follow', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_xing_type' => array(
|
||||
'personal' => esc_url( 'https://www.xing.com/profile/%powerkit_social_links_xing_slug%' ),
|
||||
'company' => esc_url( 'https://www.xing.com/companies/%powerkit_social_links_xing_slug%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_xing_type' => array(
|
||||
'title' => esc_html__( 'Profile Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'personal' => esc_html__( 'Personal', 'powerkit' ),
|
||||
'company' => esc_html__( 'Company', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_xing_slug' => esc_html__( 'Xing Company or User ID', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// LinkedIn.
|
||||
$list['linkedin'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'linkedin',
|
||||
'name' => esc_html__( 'LinkedIn', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_linkedin_channel_type' => array(
|
||||
'personal' => esc_url( 'https://www.linkedin.com/in/%powerkit_social_links_linkedin_slug%' ),
|
||||
'business' => esc_url( 'https://www.linkedin.com/company/%powerkit_social_links_linkedin_slug%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_linkedin_channel_type' => array(
|
||||
'title' => esc_html__( 'Profile Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'personal' => esc_html__( 'Personal', 'powerkit' ),
|
||||
'business' => esc_html__( 'Business', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_linkedin_slug' => esc_html__( 'LinkedIn Company or User ID', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Twitch.
|
||||
$list['twitch'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'twitch',
|
||||
'name' => esc_html__( 'Twitch', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => 'https://www.twitch.tv/%powerkit_social_links_twitch_user_id%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_twitch_user_id' => esc_html__( 'Twitch Channel ID', 'powerkit' ),
|
||||
'powerkit_social_links_twitch_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Flickr.
|
||||
$list['flickr'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'flickr',
|
||||
'name' => esc_html__( 'Flickr', 'powerkit' ),
|
||||
'label' => esc_html__( 'Follow', 'powerkit' ),
|
||||
'link' => 'https://www.flickr.com/photos/%powerkit_social_links_flickr_user_id%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_flickr_user_id' => esc_html__( 'User ID', 'powerkit' ),
|
||||
'powerkit_social_links_flickr_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Snapchat.
|
||||
$list['snapchat'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'snapchat',
|
||||
'name' => esc_html__( 'Snapchat', 'powerkit' ),
|
||||
'label' => esc_html__( 'Follow', 'powerkit' ),
|
||||
'link' => 'https://www.snapchat.com/add/%powerkit_social_links_snapchat_user%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_snapchat_user' => esc_html__( 'Account Name', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Medium.
|
||||
$list['medium'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'medium',
|
||||
'name' => esc_html__( 'Medium', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => 'https://medium.com/%powerkit_social_links_medium_user%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_medium_user' => esc_html__( 'Medium Username', 'powerkit' ) . '<p class="description">Example: @user_name</p>',
|
||||
'powerkit_social_links_medium_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Strava.
|
||||
$list['strava'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'strava',
|
||||
'name' => esc_html__( 'Strava', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => 'https://www.strava.com/athletes/%powerkit_social_links_strava_user%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_strava_user' => esc_html__( 'Strava User ID', 'powerkit' ),
|
||||
'powerkit_social_links_strava_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Tumblr.
|
||||
$list['tumblr'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'tumblr',
|
||||
'name' => esc_html__( 'Tumblr', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_tumblr_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_tumblr_url' => esc_html__( 'Tumblr URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Reddit.
|
||||
$list['reddit'] = array(
|
||||
'mode' => 'counter',
|
||||
'id' => 'reddit',
|
||||
'name' => esc_html__( 'Reddit', 'powerkit' ),
|
||||
'label' => esc_html__( 'Subscribers', 'powerkit' ),
|
||||
'link' => array(
|
||||
'powerkit_social_links_reddit_type' => array(
|
||||
'subreddit' => esc_url( 'https://www.reddit.com/r/%powerkit_social_links_reddit_user%' ),
|
||||
'user' => esc_url( 'https://www.reddit.com/user/%powerkit_social_links_reddit_user%' ),
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_reddit_type' => array(
|
||||
'title' => esc_html__( 'Type', 'powerkit' ),
|
||||
'options' => array(
|
||||
'subreddit' => esc_html__( 'Subreddit', 'powerkit' ),
|
||||
'user' => esc_html__( 'User', 'powerkit' ),
|
||||
),
|
||||
),
|
||||
'powerkit_social_links_reddit_user' => esc_html__( 'Subreddit Name or Reddit User ', 'powerkit' ),
|
||||
'powerkit_social_links_reddit_override' => esc_html__( 'Manual Count Override', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Bloglovin.
|
||||
$list['bloglovin'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'bloglovin',
|
||||
'name' => esc_html__( 'Bloglovin', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_bloglovin_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_bloglovin_url' => esc_html__( 'Bloglovin URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Weibo.
|
||||
$list['weibo'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'weibo',
|
||||
'name' => esc_html__( 'Weibo', 'powerkit' ),
|
||||
'label' => esc_html__( 'Follow', 'powerkit' ),
|
||||
'link' => 'https://www.weibo.com/%powerkit_social_links_weibo_user%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_weibo_user' => esc_html__( 'Username', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// WeChat.
|
||||
$list['wechat'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'wechat',
|
||||
'name' => esc_html__( 'WeChat', 'powerkit' ),
|
||||
'label' => esc_html__( 'Follow', 'powerkit' ),
|
||||
'link' => 'https://web.wechat.com/%powerkit_social_links_wechat_user%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_wechat_user' => esc_html__( 'Username', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// TikTok.
|
||||
$list['tiktok'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'tiktok',
|
||||
'name' => esc_html__( 'TikTok', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_tiktok_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_tiktok_url' => esc_html__( 'TikTok URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Discord.
|
||||
$list['discord'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'discord',
|
||||
'name' => esc_html__( 'Discord', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_discord_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_discord_url' => esc_html__( 'Discord URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Steam.
|
||||
$list['steam'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'steam',
|
||||
'name' => esc_html__( 'Steam', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_steam_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_steam_url' => esc_html__( 'Steam URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// TripAdvisor.
|
||||
$list['tripadvisor'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'tripadvisor',
|
||||
'name' => esc_html__( 'TripAdvisor', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_tripadvisor_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_tripadvisor_url' => esc_html__( 'TripAdvisor URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Thumbtack.
|
||||
$list['thumbtack'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'thumbtack',
|
||||
'name' => esc_html__( 'Thumbtack', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_thumbtack_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_thumbtack_url' => esc_html__( 'Thumbtack URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Android.
|
||||
$list['android'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'android',
|
||||
'name' => esc_html__( 'Android', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_android_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_android_url' => esc_html__( 'Android URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Apple.
|
||||
$list['apple'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'apple',
|
||||
'name' => esc_html__( 'Apple', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_apple_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_apple_url' => esc_html__( 'Apple URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Meetup.
|
||||
$list['meetup'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'meetup',
|
||||
'name' => esc_html__( 'Meetup', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_meetup_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_meetup_url' => esc_html__( 'Meetup URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// 500px.
|
||||
$list['500px'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => '500px',
|
||||
'name' => esc_html__( '500px', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_500px_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_500px_url' => esc_html__( '500px URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Yelp.
|
||||
$list['yelp'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'yelp',
|
||||
'name' => esc_html__( 'Yelp', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_yelp_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_yelp_url' => esc_html__( 'Yelp URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// CodePen.
|
||||
$list['codepen'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'codepen',
|
||||
'name' => esc_html__( 'CodePen', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_codepen_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_codepen_url' => esc_html__( 'CodePen URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// GitHub.
|
||||
$list['github'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'github',
|
||||
'name' => esc_html__( 'GitHub', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => esc_url( 'https://github.com/%powerkit_social_links_github_user%' ),
|
||||
'fields' => array(
|
||||
'powerkit_social_links_github_user' => esc_html__( 'GitHub User ID', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// GitLab.
|
||||
$list['gitlab'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'gitlab',
|
||||
'name' => esc_html__( 'GitLab', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_gitlab_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_gitlab_url' => esc_html__( 'GitLab URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Bitbucket.
|
||||
$list['bitbucket'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'bitbucket',
|
||||
'name' => esc_html__( 'Bitbucket', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_bitbucket_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_bitbucket_url' => esc_html__( 'Bitbucket URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// freeCodeCamp.
|
||||
$list['freecodecamp'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'freecodecamp',
|
||||
'name' => esc_html__( 'freeCodeCamp', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_freecodecamp_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_freecodecamp_url' => esc_html__( 'freeCodeCamp URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// JSFiddle.
|
||||
$list['jsfiddle'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'jsfiddle',
|
||||
'name' => esc_html__( 'JSFiddle', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_jsfiddle_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_jsfiddle_url' => esc_html__( 'JSFiddle URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Delicious.
|
||||
$list['delicious'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'delicious',
|
||||
'name' => esc_html__( 'Delicious', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_delicious_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_delicious_url' => esc_html__( 'Delicious URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// DeviantArt.
|
||||
$list['deviantart'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'deviantart',
|
||||
'name' => esc_html__( 'DeviantArt', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_deviantart_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_deviantart_url' => esc_html__( 'DeviantArt URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Foursquare.
|
||||
$list['foursquare'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'foursquare',
|
||||
'name' => esc_html__( 'Foursquare', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_foursquare_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_foursquare_url' => esc_html__( 'Foursquare URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Houzz.
|
||||
$list['houzz'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'houzz',
|
||||
'name' => esc_html__( 'Houzz', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_houzz_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_houzz_url' => esc_html__( 'Houzz URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Product Hunt.
|
||||
$list['producthunt'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'producthunt',
|
||||
'name' => esc_html__( 'Product Hunt', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_producthunt_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_producthunt_url' => esc_html__( 'Product Hunt URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Slideshare.
|
||||
$list['slideshare'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'slideshare',
|
||||
'name' => esc_html__( 'Slideshare', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_slideshare_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_slideshare_url' => esc_html__( 'Slideshare URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Goodreads.
|
||||
$list['goodreads'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'goodreads',
|
||||
'name' => esc_html__( 'Goodreads', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_goodreads_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_goodreads_url' => esc_html__( 'Goodreads URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Mastodon.
|
||||
$list['mastodon'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'mastodon',
|
||||
'name' => esc_html__( 'Mastodon', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_mastodon_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_mastodon_url' => esc_html__( 'Mastodon URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// PixelFed.
|
||||
$list['pixelfed'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'pixelfed',
|
||||
'name' => esc_html__( 'PixelFed', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_pixelfed_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_pixelfed_url' => esc_html__( 'PixelFed URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Micro.blog.
|
||||
$list['microblog'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'microblog',
|
||||
'name' => esc_html__( 'Micro.blog', 'powerkit' ),
|
||||
'label' => esc_html__( 'Followers', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_microblog_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_microblog_url' => esc_html__( 'Micro.blog URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Phone.
|
||||
$list['phone'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'phone',
|
||||
'name' => esc_html__( 'Phone', 'powerkit' ),
|
||||
'label' => esc_html__( 'phone', 'powerkit' ),
|
||||
'link' => 'tel:%powerkit_social_links_phone_tel%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_phone_tel' => esc_html__( 'Phone', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Viber.
|
||||
$list['viber'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'viber',
|
||||
'name' => esc_html__( 'Viber', 'powerkit' ),
|
||||
'label' => esc_html__( 'Call', 'powerkit' ),
|
||||
'link' => 'tel:%powerkit_social_links_viber_tel%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_viber_tel' => esc_html__( 'Phone', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// WhatsApp.
|
||||
$list['whatsapp'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'whatsapp',
|
||||
'name' => esc_html__( 'WhatsApp', 'powerkit' ),
|
||||
'label' => esc_html__( 'Call', 'powerkit' ),
|
||||
'link' => 'tel:%powerkit_social_links_whatsapp_tel%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_whatsapp_tel' => esc_html__( 'Phone', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Mail.
|
||||
$list['mail'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'mail',
|
||||
'name' => esc_html__( 'Mail', 'powerkit' ),
|
||||
'label' => esc_html__( 'Send', 'powerkit' ),
|
||||
'link' => 'mailto:%powerkit_social_links_email%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_email' => esc_html__( 'Email', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
// RSS.
|
||||
$list['rss'] = array(
|
||||
'mode' => 'simple',
|
||||
'id' => 'rss',
|
||||
'name' => esc_html__( 'RSS', 'powerkit' ),
|
||||
'label' => esc_html__( 'Feed', 'powerkit' ),
|
||||
'link' => '%powerkit_social_links_rss_url%',
|
||||
'fields' => array(
|
||||
'powerkit_social_links_rss_url' => esc_html__( 'RSS URL', 'powerkit' ),
|
||||
),
|
||||
);
|
||||
|
||||
return $list;
|
||||
}
|
||||
add_filter( 'powerkit_social_links_list', 'powerkit_social_links_list' );
|
||||
@@ -0,0 +1,623 @@
|
||||
<?php
|
||||
/**
|
||||
* Helpers Social Links
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Helper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Author social fields
|
||||
*/
|
||||
function powerkit_get_author_fields() {
|
||||
return array(
|
||||
'facebook' => esc_html__( 'Facebook Profile URL', 'powerkit' ),
|
||||
'twitter' => esc_html__( 'Twitter Profile URL', 'powerkit' ),
|
||||
'instagram' => esc_html__( 'Instagram Profile URL', 'powerkit' ),
|
||||
'pinterest' => esc_html__( 'Pinterest Profile URL', 'powerkit' ),
|
||||
'youtube' => esc_html__( 'YouTube Profile URL', 'powerkit' ),
|
||||
'telegram' => esc_html__( 'Telegram Profile URL', 'powerkit' ),
|
||||
'vimeo' => esc_html__( 'Vimeo Profile URL', 'powerkit' ),
|
||||
'soundcloud' => esc_html__( 'SoundCloud Profile URL', 'powerkit' ),
|
||||
'spotify' => esc_html__( 'Spotify Profile URL', 'powerkit' ),
|
||||
'dribbble' => esc_html__( 'Dribbble Profile URL', 'powerkit' ),
|
||||
'behance' => esc_html__( 'Behance Profile URL', 'powerkit' ),
|
||||
'github' => esc_html__( 'GitHub Profile URL', 'powerkit' ),
|
||||
'vk' => esc_html__( 'VK Profile URL', 'powerkit' ),
|
||||
'linkedin' => esc_html__( 'LinkedIn Profile URL', 'powerkit' ),
|
||||
'twitch' => esc_html__( 'Twitch Profile URL', 'powerkit' ),
|
||||
'flickr' => esc_html__( 'Flickr Profile URL', 'powerkit' ),
|
||||
'snapchat' => esc_html__( 'Snapchat Profile URL', 'powerkit' ),
|
||||
'medium' => esc_html__( 'Medium Profile URL', 'powerkit' ),
|
||||
'tumblr' => esc_html__( 'Tumblr Profile URL', 'powerkit' ),
|
||||
'bloglovin' => esc_html__( 'Bloglovin Profile URL', 'powerkit' ),
|
||||
'rss' => esc_html__( 'RSS Profile URL', 'powerkit' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author Social Links
|
||||
*
|
||||
* @param mixed $author The author.
|
||||
* @param string $class Class name of the wrapping <div>.
|
||||
* @param bool $title Title of the link.
|
||||
* @param bool $only_data Output only data.
|
||||
*/
|
||||
function powerkit_author_social_links( $author, $class = 'default', $title = false, $only_data = false ) {
|
||||
|
||||
$links = powerkit_get_author_fields();
|
||||
|
||||
$list = array();
|
||||
|
||||
// Website.
|
||||
$url = get_the_author_meta( 'url', $author );
|
||||
|
||||
if ( $url ) {
|
||||
$list[] = array(
|
||||
'label' => esc_html__( 'Website', 'powerkit' ),
|
||||
'key' => 'website',
|
||||
'url' => $url,
|
||||
);
|
||||
}
|
||||
|
||||
// Loop through the array of social links.
|
||||
foreach ( $links as $key => $label ) {
|
||||
|
||||
if ( isset( $author->$key ) ) {
|
||||
$author_url = $author->$key;
|
||||
} else {
|
||||
$author_url = get_the_author_meta( $key, $author );
|
||||
}
|
||||
|
||||
if ( empty( $author_url ) ) {
|
||||
$author_url = get_post_meta( $author, sprintf( 'cap-%s', $key ), true );
|
||||
}
|
||||
|
||||
// Check if slug of a social icon is not empty.
|
||||
if ( $author_url ) {
|
||||
$list[] = array(
|
||||
'url' => $author_url,
|
||||
'key' => $key,
|
||||
'label' => $label,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $only_data ) {
|
||||
return $list;
|
||||
}
|
||||
|
||||
// Link Attributes.
|
||||
$target = get_option( 'powerkit_social_links_link_target', 'new' ) === 'new' ? '_blank' : '_self';
|
||||
$rel = get_option( 'powerkit_social_links_nofollow' ) ? 'nofollow' : '';
|
||||
|
||||
// Check if the list is not empty.
|
||||
if ( $list ) {
|
||||
?>
|
||||
<div class="pk-author-social-links pk-social-links-wrap pk-social-links-template-<?php echo esc_html( $class ); ?>">
|
||||
<div class="pk-social-links-items">
|
||||
<?php
|
||||
// Loop through the array of social links.
|
||||
foreach ( $list as $data ) {
|
||||
?>
|
||||
<div class="pk-social-links-item pk-social-links-<?php echo esc_html( $data['key'] ); ?>">
|
||||
<a href="<?php echo esc_url( $data['url'] ); ?>" class="pk-social-links-link" target="<?php echo esc_attr( $target ); ?>" rel="<?php echo esc_attr( $rel ); ?>">
|
||||
<i class="pk-icon pk-icon-<?php echo esc_html( $data['key'] ); ?>"></i>
|
||||
<?php if ( $title ) { ?>
|
||||
<span class="pk-social-links-title pk-font-primary"><?php echo esc_html( $data['label'] ); ?></span>
|
||||
<?php } ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get social params with filter
|
||||
*
|
||||
* @param string $id ID group.
|
||||
* @param string $key Filter key.
|
||||
* @return mix Specific social params.
|
||||
*/
|
||||
function powerkit_social_links_specific_param( $id, $key = false ) {
|
||||
$params = apply_filters( 'powerkit_social_links_list', array() );
|
||||
|
||||
foreach ( $params as $param ) {
|
||||
if ( $key ) {
|
||||
if ( $param['id'] === $id && isset( $param[ $key ] ) ) {
|
||||
return $param[ $key ];
|
||||
}
|
||||
} else {
|
||||
if ( $param['id'] === $id ) {
|
||||
return $param;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get templates options
|
||||
*
|
||||
* @return array Items.
|
||||
*/
|
||||
function powerkit_social_links_get_templates() {
|
||||
$options = array();
|
||||
|
||||
$templates = apply_filters( 'powerkit_social_links_templates', array() );
|
||||
|
||||
if ( $templates ) {
|
||||
foreach ( $templates as $key => $item ) {
|
||||
if ( isset( $item['public'] ) && false === $item['public'] ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $item['name'] ) ) {
|
||||
$options[ $key ] = $item['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color schemes options
|
||||
*
|
||||
* @return array Items.
|
||||
*/
|
||||
function powerkit_social_links_get_color_schemes() {
|
||||
$options = array();
|
||||
|
||||
$color_schemes = apply_filters( 'powerkit_social_links_color_schemes', array() );
|
||||
|
||||
if ( $color_schemes ) {
|
||||
foreach ( $color_schemes as $key => $item ) {
|
||||
if ( isset( $item['public'] ) && false === $item['public'] ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $item['name'] ) ) {
|
||||
$options[ $key ] = $item['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adapt link with option
|
||||
*
|
||||
* @param array $link Url link social.
|
||||
* @param string $slug The slug default.
|
||||
*/
|
||||
function powerkit_social_links_parse_link( $link, $slug = null ) {
|
||||
|
||||
$parse = array();
|
||||
|
||||
if ( is_array( $link ) ) {
|
||||
foreach ( $link as $extra_name => $links ) {
|
||||
$link_type = get_option( $extra_name );
|
||||
foreach ( $links as $type => $url ) {
|
||||
if ( $link_type === $type ) {
|
||||
$link = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_array( $link ) ) {
|
||||
preg_match( '/%(powerkit_social_links_.*?)%/', $link, $parse );
|
||||
|
||||
if ( ! $slug ) {
|
||||
$slug = get_option( $parse[1] );
|
||||
}
|
||||
|
||||
// Return replaced value.
|
||||
if ( isset( $parse[0] ) && isset( $parse[1] ) ) {
|
||||
return str_replace( $parse[0], $slug, $link );
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
// Return empty value.
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template appearance
|
||||
*
|
||||
* @param array $params Parameters.
|
||||
*/
|
||||
function powerkit_social_links_appearance( $params ) {
|
||||
|
||||
$wrap_class = null;
|
||||
|
||||
$params = array_merge(
|
||||
array(
|
||||
'cache' => true,
|
||||
'maximum' => -1,
|
||||
'template' => 'inline',
|
||||
'align' => 'default',
|
||||
'scheme' => 'light',
|
||||
'labels' => true,
|
||||
'titles' => true,
|
||||
'counts' => true,
|
||||
'mode' => 'mixed',
|
||||
),
|
||||
(array) $params
|
||||
);
|
||||
|
||||
// Socials list.
|
||||
$links = array();
|
||||
|
||||
$social_links_order = get_option( 'powerkit_social_links_order_multiple_list', array() );
|
||||
$social_links_check = get_option( 'powerkit_social_links_multiple_list', array() );
|
||||
|
||||
// Sort.
|
||||
if ( $social_links_order && $social_links_check ) {
|
||||
$social_links_order = array_flip( $social_links_order );
|
||||
|
||||
foreach ( $social_links_order as $key => $val ) {
|
||||
if ( in_array( $key, $social_links_check, true ) ) {
|
||||
$links[] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Maximum.
|
||||
if ( isset( $params['maximum'] ) && intval( $params['maximum'] ) > 0 ) {
|
||||
$links = array_slice( $links, 0, $params['maximum'], true );
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------- Build Template.
|
||||
*/
|
||||
|
||||
// Template columns.
|
||||
if ( in_array( $params['template'], array( 'col-2', 'col-3', 'col-4', 'col-5', 'col-6' ), true ) ) {
|
||||
$wrap_class .= ' pk-social-links-template-columns';
|
||||
}
|
||||
|
||||
// Wrap Class.
|
||||
$wrap_class .= sprintf( ' pk-social-links-template-%s', $params['template'] );
|
||||
|
||||
// Align Class.
|
||||
$wrap_class .= sprintf( ' pk-social-links-align-%s', $params['align'] );
|
||||
|
||||
/*
|
||||
* ---------- Build Scheme.
|
||||
*/
|
||||
|
||||
// Light Background.
|
||||
if ( 'light-bg' === $params['scheme'] ) {
|
||||
$wrap_class .= ' pk-social-links-scheme-light';
|
||||
}
|
||||
|
||||
// Light Rounded.
|
||||
if ( 'light-rounded' === $params['scheme'] ) {
|
||||
$wrap_class .= ' pk-social-links-scheme-bold';
|
||||
}
|
||||
|
||||
// Wrap Color scheme.
|
||||
$wrap_class .= sprintf( ' pk-social-links-scheme-%s', $params['scheme'] );
|
||||
|
||||
// Wrap Class | Counts, titles, labels.
|
||||
$wrap_class .= ( $params['titles'] ) ? ' pk-social-links-titles-enabled' : ' pk-social-links-titles-disabled';
|
||||
$wrap_class .= ( $params['counts'] ) ? ' pk-social-links-counts-enabled' : ' pk-social-links-counts-disabled';
|
||||
$wrap_class .= ( $params['labels'] ) ? ' pk-social-links-labels-enabled' : ' pk-social-links-labels-disabled';
|
||||
|
||||
if ( $params['counts'] ) {
|
||||
switch ( $params['mode'] ) {
|
||||
case 'php':
|
||||
$wrap_class .= ' pk-social-links-mode-php';
|
||||
break;
|
||||
|
||||
case 'rest':
|
||||
$wrap_class .= ' pk-social-links-mode-rest';
|
||||
|
||||
// Smart Load restapi scripts.
|
||||
add_action( 'wp_footer', 'powerkit_social_links_rest_api_scripts', 99 );
|
||||
break;
|
||||
case 'mixed':
|
||||
$wrap_class .= ' pk-social-links-mode-php';
|
||||
$wrap_class .= ' pk-social-links-mode-rest';
|
||||
|
||||
// Smart Load restapi scripts.
|
||||
add_action( 'wp_footer', 'powerkit_social_links_rest_api_scripts', 99 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Link Attributes.
|
||||
$target = get_option( 'powerkit_social_links_link_target', 'new' ) === 'new' ? '_blank' : '_self';
|
||||
$rel = get_option( 'powerkit_social_links_nofollow' ) ? 'nofollow noopener' : '';
|
||||
|
||||
// Icon prefix.
|
||||
$powerkit_social_links_icon_prefix = apply_filters( 'powerkit_social_links_icon_prefix', 'pk-icon' );
|
||||
?>
|
||||
<div class="pk-social-links-wrap <?php echo esc_attr( $wrap_class ); ?>">
|
||||
<div class="pk-social-links-items">
|
||||
<?php
|
||||
if ( $links ) {
|
||||
foreach ( $links as $item ) {
|
||||
$id = is_array( $item ) ? $item['id'] : $item;
|
||||
|
||||
$title = get_option( sprintf( 'powerkit_social_links_title_%s', $id ) );
|
||||
$label = get_option( sprintf( 'powerkit_social_links_label_%s', $id ) );
|
||||
|
||||
// Mode.
|
||||
$link_mode = powerkit_social_links_specific_param( $id, 'mode' );
|
||||
|
||||
// Link User.
|
||||
$link = powerkit_social_links_parse_link( powerkit_social_links_specific_param( $id, 'link' ) );
|
||||
|
||||
// Account Count.
|
||||
$result = array();
|
||||
|
||||
if ( $params['counts'] ) {
|
||||
if ( 'rest' === $params['mode'] ) {
|
||||
$result = powerkit_social_links_get_count( $id, 'forcibly', true ); // Count User.
|
||||
} else {
|
||||
$result = powerkit_social_links_get_count( $id, $params['cache'], true ); // Count User.
|
||||
}
|
||||
}
|
||||
|
||||
$class = ( ! isset( $result['count'] ) || ! $result['count'] ) ? ' pk-social-links-no-count' : '';
|
||||
?>
|
||||
<div class="pk-social-links-item pk-social-links-<?php echo esc_attr( $id ); ?> <?php echo esc_attr( $class ); ?>" data-id="<?php echo esc_attr( $id ); ?>">
|
||||
<a href="<?php echo esc_url( $link ); ?>" class="pk-social-links-link" target="<?php echo esc_attr( $target ); ?>" rel="<?php echo esc_attr( $rel ); ?>" aria-label="<?php echo esc_html( $title ); ?>">
|
||||
<i class="pk-social-links-icon <?php echo sprintf( '%2$s %2$s-%1$s', esc_attr( $id ), esc_attr( $powerkit_social_links_icon_prefix ) ); ?>"></i>
|
||||
<?php if ( $params['titles'] && $title ) { ?>
|
||||
<span class="pk-social-links-title pk-font-heading"><?php echo esc_html( $title ); ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( $params['counts'] ) { ?>
|
||||
<span class="pk-social-links-count pk-font-secondary"><?php echo esc_html( isset( $result['count'] ) ? $result['count'] : 0 ); ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( isset( $result['error'] ) && ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) ) { ?>
|
||||
<span class="pk-social-links-count pk-font-secondary pk-social-links-note pk-tippy">
|
||||
<span class="pk-social-links-note-icon"></span>
|
||||
|
||||
<?php powerkit_alert_warning( powerkit_social_links_specific_param( $id, 'name' ) . ' : ' . $result['error'] ); ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( $params['labels'] && $label && ( 'counter' === $link_mode ) ) { ?>
|
||||
<span class="pk-social-links-label pk-font-secondary"><?php echo esc_html( $label ); ?></span>
|
||||
<?php } ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
/* translators: Social Settings Link. */
|
||||
powerkit_alert_warning( sprintf( __( 'Please select social links in <object><a href="%s" target="_blank">Social Links Settings</a></object>.', 'powerkit' ), esc_url( powerkit_get_page_url( 'social_links' ) ) ) );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function get social links
|
||||
*
|
||||
* @param bool $labels Display labels.
|
||||
* @param bool $titles Display titles.
|
||||
* @param bool $counts Display counts.
|
||||
* @param string $template Template links.
|
||||
* @param string $scheme Color scheme.
|
||||
* @param string $mode Counter mode.
|
||||
* @param mixed $maximum Maximum Number of Social Links.
|
||||
*/
|
||||
function powerkit_social_links( $labels = true, $titles = true, $counts = true, $template = 'inline', $scheme = 'light', $mode = 'mixed', $maximum = -1 ) {
|
||||
$params = array(
|
||||
'labels' => $labels,
|
||||
'titles' => $titles,
|
||||
'counts' => $counts,
|
||||
'template' => $template,
|
||||
'scheme' => $scheme,
|
||||
'mode' => $mode,
|
||||
'maximum' => $maximum,
|
||||
'cache' => true,
|
||||
);
|
||||
|
||||
powerkit_social_links_appearance( $params );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Social Links REST API Scripts
|
||||
*/
|
||||
function powerkit_social_links_rest_api_scripts() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
(function($) {
|
||||
|
||||
$( window ).on( 'load', function() {
|
||||
|
||||
// Get all links.
|
||||
var powerkitSLinksIds = [];
|
||||
|
||||
var powerkitSLinksRestBox = $( '.pk-social-links-mode-rest' );
|
||||
|
||||
// Generate links Ids.
|
||||
$( powerkitSLinksRestBox ).each( function( index, wrap ) {
|
||||
|
||||
if ( ! $( wrap ).hasClass( 'pk-social-links-counts-disabled' ) ) {
|
||||
|
||||
$( wrap ).find( '.pk-social-links-item' ).each( function() {
|
||||
if ( $( this ).attr( 'data-id' ).length > 0 ) {
|
||||
powerkitSLinksIds.push( $( this ).attr( 'data-id' ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Generate links data.
|
||||
var powerkitSLinksData = {};
|
||||
|
||||
if( powerkitSLinksIds.length > 0 ) {
|
||||
powerkitSLinksData = { 'ids' : powerkitSLinksIds.join() };
|
||||
}
|
||||
|
||||
// Check data.
|
||||
if ( ! Object.entries( powerkitSLinksData ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get results by REST API.
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '<?php echo esc_url( get_rest_url( null, '/social-counts/v1/get-counts' ) ); ?>',
|
||||
data: powerkitSLinksData,
|
||||
beforeSend: function(){
|
||||
|
||||
// Add Loading Class.
|
||||
powerkitSLinksRestBox.addClass( 'pk-social-links-loading' );
|
||||
},
|
||||
success: function( response ) {
|
||||
|
||||
if ( ! $.isEmptyObject( response ) && ! response.hasOwnProperty( 'code' ) ) {
|
||||
|
||||
// SLinks loop.
|
||||
$.each( response, function( index, data ) {
|
||||
|
||||
// Find Bsa Item.
|
||||
var powerkitSLinksItem = powerkitSLinksRestBox.find( '.pk-social-links-item[data-id="' + index + '"]');
|
||||
|
||||
// Set Class.
|
||||
if ( data.hasOwnProperty( 'class' ) ) {
|
||||
powerkitSLinksItem.addClass( data.class );
|
||||
}
|
||||
|
||||
// Set Count.
|
||||
if ( data.hasOwnProperty( 'result' ) && data.result !== null && data.result.hasOwnProperty( 'count' ) ) {
|
||||
|
||||
if ( data.result.count ) {
|
||||
// Class Item.
|
||||
powerkitSLinksItem.removeClass( 'pk-social-links-no-count' ).addClass( 'pk-social-links-item-count' );
|
||||
|
||||
// Count item.
|
||||
powerkitSLinksItem.find( '.pk-social-links-count' ).not( '.pk-tippy' ).html( data.result.count );
|
||||
}
|
||||
} else {
|
||||
powerkitSLinksItem.addClass( 'pk-social-links-no-count' );
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Remove Loading Class.
|
||||
powerkitSLinksRestBox.removeClass( 'pk-social-links-loading' );
|
||||
},
|
||||
error: function() {
|
||||
|
||||
// Remove Loading Class.
|
||||
powerkitSLinksRestBox.removeClass( 'pk-social-links-loading' );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is our callback function that embeds our resource in a WP_REST_Response
|
||||
*
|
||||
* @param array $request REST API Request.
|
||||
*/
|
||||
function powerkit_social_links_restapi( $request ) {
|
||||
|
||||
// Get Social Links.
|
||||
$social_social_links = apply_filters( 'powerkit_social_links_list', array() );
|
||||
$social_social_links = array_keys( $social_social_links );
|
||||
|
||||
// Error, when Social Links are empty.
|
||||
if ( empty( $social_social_links ) ) {
|
||||
return rest_ensure_response(
|
||||
array(
|
||||
'code' => 'social_links_not_found',
|
||||
'message' => esc_html__( 'Social Links not found.', 'powerkit' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Labels.
|
||||
if ( isset( $request['labels'] ) ) {
|
||||
$labels = (bool) $request['labels'];
|
||||
} else {
|
||||
$labels = false;
|
||||
}
|
||||
|
||||
// Cache Results.
|
||||
if ( isset( $request['cache'] ) ) {
|
||||
$cache = (bool) $request['cache'];
|
||||
} else {
|
||||
$cache = true;
|
||||
}
|
||||
|
||||
// Get Counts.
|
||||
$link_counts = array();
|
||||
|
||||
if ( isset( $request['ids'] ) ) {
|
||||
$ids = explode( ',', $request['ids'] );
|
||||
$ids = array_map( 'trim', $ids );
|
||||
} else {
|
||||
$ids = $social_social_links;
|
||||
}
|
||||
|
||||
foreach ( $ids as $link_id ) {
|
||||
if ( in_array( $link_id, $social_social_links, true ) ) {
|
||||
|
||||
$result = powerkit_social_links_get_count( $link_id, $cache, true ); // Count User.
|
||||
|
||||
$class = ( ! isset( $result['count'] ) || ! $result['count'] ) ? ' pk-social-links-no-count' : '';
|
||||
$class .= ( isset( $result['error'] ) ) ? ' pk-social-links-error' : '';
|
||||
|
||||
$link_counts[ $link_id ] = array(
|
||||
'result' => $result,
|
||||
'class' => $class,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Return Succes Result.
|
||||
return rest_ensure_response( $link_counts );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is where we register our routes for our example endpoint.
|
||||
*/
|
||||
function powerkit_social_links_register_api_routes() {
|
||||
|
||||
register_rest_route(
|
||||
'social-counts/v1',
|
||||
'/get-counts',
|
||||
array(
|
||||
// By using this constant we ensure that when the WP_REST_Server changes our readable endpoints will work as intended.
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
// Here we register our callback. The callback is fired when this endpoint is matched by the WP_REST_Server class.
|
||||
'callback' => 'powerkit_social_links_restapi',
|
||||
'permission_callback' => function() {
|
||||
return true;
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'rest_api_init', 'powerkit_social_links_register_api_routes' );
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Social Links block template
|
||||
*
|
||||
* @var $attributes - block attributes
|
||||
* @var $options - layout options
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package PowerKit
|
||||
* @subpackage PowerKit/templates
|
||||
*/
|
||||
|
||||
$params = array(
|
||||
'title' => esc_html__( 'Social Links', 'powerkit' ),
|
||||
'template' => $attributes['template'],
|
||||
'align' => isset( $attributes['aligning'] ) ? $attributes['aligning'] : 'default',
|
||||
'scheme' => 'gutenberg-block',
|
||||
'maximum' => $attributes['count'],
|
||||
'cache' => true,
|
||||
'labels' => $attributes['showLabels'],
|
||||
'titles' => $attributes['showTitles'],
|
||||
'counts' => $attributes['showCounts'],
|
||||
'mode' => apply_filters( 'powerkit_social_links_counter_mode', 'mixed' ),
|
||||
);
|
||||
|
||||
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>';
|
||||
|
||||
powerkit_social_links_appearance( $params );
|
||||
|
||||
echo '</div>';
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* The Gutenberg Block.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The initialize block.
|
||||
*/
|
||||
class Powerkit_Social_Links_Block {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'block' ) );
|
||||
add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the block's assets for the editor.
|
||||
*/
|
||||
public function block() {
|
||||
// Styles.
|
||||
wp_register_style(
|
||||
'powerkit-social-links-block-editor-style',
|
||||
plugins_url( 'css/public-powerkit-social-links.css', __FILE__ ),
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-social-links.css' )
|
||||
);
|
||||
|
||||
wp_style_add_data( 'powerkit-social-links-block-editor-style', 'rtl', 'replace' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @param array $blocks all registered blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function register_block_type( $blocks ) {
|
||||
$additional_fields = array();
|
||||
$styles = array();
|
||||
$colors = apply_filters( 'powerkit_social_links_color_schemes', array() );
|
||||
$templates = powerkit_social_links_get_templates();
|
||||
|
||||
// Colors.
|
||||
if ( count( (array) $colors ) > 1 ) {
|
||||
foreach ( $colors as $name => $scheme ) {
|
||||
$styles[] = array(
|
||||
'name' => 'pk-social-links-' . $name,
|
||||
'label' => $scheme['name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Templates.
|
||||
if ( count( (array) $templates ) > 1 ) {
|
||||
$additional_fields[] = array(
|
||||
'key' => 'template',
|
||||
'label' => esc_html__( 'Template', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'default' => 'inline',
|
||||
'choices' => $templates,
|
||||
);
|
||||
|
||||
$additional_fields[] = array(
|
||||
'key' => 'aligning',
|
||||
'label' => esc_html__( 'Aligning Items', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'select',
|
||||
'default' => 'default',
|
||||
'choices' => array(
|
||||
'default' => esc_html__( 'Default', 'powerkit' ),
|
||||
'left' => esc_html__( 'Left', 'powerkit' ),
|
||||
'center' => esc_html__( 'Center', 'powerkit' ),
|
||||
'right' => esc_html__( 'Right', 'powerkit' ),
|
||||
),
|
||||
'active_callback' => array(
|
||||
array(
|
||||
'field' => 'template',
|
||||
'operator' => '==',
|
||||
'value' => 'inline',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$blocks[] = array(
|
||||
'name' => 'canvas/social-links',
|
||||
'title' => esc_html__( 'Social Links', 'powerkit' ),
|
||||
'category' => 'canvas',
|
||||
'keywords' => array(),
|
||||
'icon' => '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path fill="none" d="M0 0h24v24H0z"/><g stroke="#2D2D2D" stroke-width="1.5"><path d="M10 12.83a5.45 5.45 0 003.97 2.156 5.46 5.46 0 004.237-1.571l3.265-3.246a5.387 5.387 0 00-.066-7.584 5.465 5.465 0 00-7.63-.066l-1.871 1.85"/><path d="M14 11.17a5.45 5.45 0 00-3.97-2.156 5.46 5.46 0 00-4.237 1.571l-3.265 3.246a5.387 5.387 0 00.066 7.584 5.465 5.465 0 007.63.066l1.86-1.85"/></g></g></svg>',
|
||||
'supports' => array(
|
||||
'className' => true,
|
||||
'anchor' => true,
|
||||
'html' => false,
|
||||
'canvasSpacings' => true,
|
||||
'canvasBorder' => true,
|
||||
'canvasResponsive' => true,
|
||||
),
|
||||
'styles' => $styles,
|
||||
'location' => array(),
|
||||
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'title' => esc_html__( 'Block Settings', 'powerkit' ),
|
||||
'priority' => 5,
|
||||
'open' => true,
|
||||
),
|
||||
),
|
||||
'layouts' => array(),
|
||||
'fields' => array_merge(
|
||||
$additional_fields,
|
||||
array(
|
||||
array(
|
||||
'key' => 'showLabels',
|
||||
'label' => esc_html__( 'Display Labels', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showTitles',
|
||||
'label' => esc_html__( 'Display Titles', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'showCounts',
|
||||
'label' => esc_html__( 'Display Counts', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'toggle',
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'key' => 'count',
|
||||
'label' => esc_html__( 'Maximum number of social links', 'powerkit' ),
|
||||
'help' => esc_html__( 'Input -1 to remove the maximum limit of the social links.', 'powerkit' ),
|
||||
'section' => 'general',
|
||||
'type' => 'number',
|
||||
'min' => -1,
|
||||
'max' => 50,
|
||||
'default' => -1,
|
||||
),
|
||||
)
|
||||
),
|
||||
'template' => dirname( __FILE__ ) . '/block/render.php',
|
||||
|
||||
// enqueue registered scripts/styles.
|
||||
'editor_style' => 'powerkit-social-links-block-editor-style',
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
}
|
||||
|
||||
new Powerkit_Social_Links_Block();
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the module.
|
||||
*/
|
||||
class Powerkit_Social_Links_Public extends Powerkit_Module_Public {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_filter( 'powerkit_social_links_templates', array( $this, 'templates_default' ) );
|
||||
add_filter( 'powerkit_social_links_color_schemes', array( $this, 'schemes_default' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Templates
|
||||
*
|
||||
* @param array $templates List of Templates.
|
||||
*/
|
||||
public function templates_default( $templates = array() ) {
|
||||
$templates = array(
|
||||
'inline' => array(
|
||||
'name' => 'Inline',
|
||||
),
|
||||
'col-2' => array(
|
||||
'name' => '2 columns',
|
||||
),
|
||||
'col-3' => array(
|
||||
'name' => '3 columns',
|
||||
),
|
||||
'col-4' => array(
|
||||
'name' => '4 columns',
|
||||
),
|
||||
'col-5' => array(
|
||||
'name' => '5 columns',
|
||||
),
|
||||
'col-6' => array(
|
||||
'name' => '6 columns',
|
||||
),
|
||||
'vertical' => array(
|
||||
'name' => 'Vertical List',
|
||||
),
|
||||
'nav' => array(
|
||||
'name' => 'Navigation',
|
||||
'public' => false,
|
||||
),
|
||||
);
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Register Color Schemes
|
||||
*
|
||||
* @param array $schemes List of Color Schemes.
|
||||
*/
|
||||
public function schemes_default( $schemes = array() ) {
|
||||
|
||||
$schemes = array(
|
||||
'light' => array(
|
||||
'name' => 'Light',
|
||||
),
|
||||
'bold' => array(
|
||||
'name' => 'Bold',
|
||||
),
|
||||
'inverse' => array(
|
||||
'name' => 'Inverse',
|
||||
),
|
||||
'light-bg' => array(
|
||||
'name' => 'Light Background',
|
||||
),
|
||||
'bold-bg' => array(
|
||||
'name' => 'Bold Background',
|
||||
),
|
||||
'dark-bg' => array(
|
||||
'name' => 'Dark Background',
|
||||
),
|
||||
'light-rounded' => array(
|
||||
'name' => 'Light Rounded',
|
||||
),
|
||||
'bold-rounded' => array(
|
||||
'name' => 'Bold Rounded',
|
||||
),
|
||||
'dark-rounded' => array(
|
||||
'name' => 'Dark Rounded',
|
||||
),
|
||||
);
|
||||
|
||||
return $schemes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*/
|
||||
public function wp_enqueue_scripts() {
|
||||
wp_enqueue_style( 'powerkit-social-links', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/public-powerkit-social-links.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
// Add RTL support.
|
||||
wp_style_add_data( 'powerkit-social-links', 'rtl', 'replace' );
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Shortcode Social Links
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/shortcodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Social Account Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_social_link_shortcode( $atts, $content = '' ) {
|
||||
$params = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'network' => false,
|
||||
'cache' => true,
|
||||
'mode' => apply_filters( 'powerkit_social_links_counter_mode', 'mixed' ),
|
||||
), $atts ) );
|
||||
|
||||
$params['cache'] = filter_var( $params['cache'], FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
if ( $params['network'] ) {
|
||||
return powerkit_social_links_get_count( $params['network'], $params['cache'] );
|
||||
} else {
|
||||
return esc_html__( 'Network name is incorrect!', 'powerkit' );
|
||||
}
|
||||
}
|
||||
add_shortcode( 'powerkit_social_link', 'powerkit_social_link_shortcode' );
|
||||
|
||||
|
||||
/**
|
||||
* Social Links Shortcode
|
||||
*
|
||||
* @param array $atts User defined attributes in shortcode tag.
|
||||
* @param string $content Shorcode tag content.
|
||||
* @return string Shortcode result HTML.
|
||||
*/
|
||||
function powerkit_social_links_shortcode( $atts, $content = '' ) {
|
||||
$params = powerkit_shortcode_atts( shortcode_atts( array(
|
||||
'title' => esc_html__( 'Social Links', 'powerkit' ),
|
||||
'template' => 'inline',
|
||||
'scheme' => 'light',
|
||||
'maximum' => -1,
|
||||
'cache' => true,
|
||||
'labels' => true,
|
||||
'titles' => true,
|
||||
'counts' => true,
|
||||
'mode' => apply_filters( 'powerkit_social_links_counter_mode', 'mixed' ),
|
||||
), $atts ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
$params['cache'] = filter_var( $params['cache'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['labels'] = filter_var( $params['labels'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['titles'] = filter_var( $params['titles'], FILTER_VALIDATE_BOOLEAN );
|
||||
$params['counts'] = filter_var( $params['counts'], FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
powerkit_social_links_appearance( $params );
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
add_shortcode( 'powerkit_social_links', 'powerkit_social_links_shortcode' );
|
||||
|
||||
/**
|
||||
* Map Social Links Shortcode into the Basic Shortcodes Plugin
|
||||
*/
|
||||
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) :
|
||||
|
||||
add_action( 'init', function() {
|
||||
|
||||
$shortcode_map = array(
|
||||
'name' => 'links',
|
||||
'title' => esc_html__( 'Social Links', 'powerkit' ),
|
||||
'priority' => 110,
|
||||
'base' => 'powerkit_social_links',
|
||||
'autoregister' => false,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'labels',
|
||||
'label' => esc_html__( 'Labels', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'titles',
|
||||
'label' => esc_html__( 'Titles', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'counts',
|
||||
'label' => esc_html__( 'Counts', 'powerkit' ),
|
||||
'default' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'input',
|
||||
'name' => 'maximum',
|
||||
'label' => esc_html__( 'Maximum number of social links', 'powerkit' ),
|
||||
'desc' => esc_html__( 'Input -1 to remove the maximum limit of the social links.', 'powerkit' ),
|
||||
'default' => -1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$templates = apply_filters( 'powerkit_social_links_templates', array() );
|
||||
|
||||
if ( count( (array) $templates ) > 1 ) {
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'select',
|
||||
'name' => 'template',
|
||||
'label' => esc_html__( 'Template', 'powerkit' ),
|
||||
'default' => 'default',
|
||||
'options' => powerkit_social_links_get_templates(),
|
||||
);
|
||||
}
|
||||
|
||||
$color_schemes = apply_filters( 'powerkit_social_links_color_schemes', array() );
|
||||
|
||||
if ( count( (array) $color_schemes ) > 1 ) {
|
||||
$shortcode_map['fields'][] = array(
|
||||
'type' => 'select',
|
||||
'name' => 'scheme',
|
||||
'label' => esc_html__( 'Color scheme', 'powerkit' ),
|
||||
'default' => 'default',
|
||||
'options' => powerkit_social_links_get_color_schemes(),
|
||||
);
|
||||
}
|
||||
|
||||
powerkit_basic_shortcodes_register( $shortcode_map );
|
||||
|
||||
});
|
||||
|
||||
endif;
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Social Links
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Powerkit/widgets
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget Social Links
|
||||
*/
|
||||
class Powerkit_Social_Links_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Sets up a new widget instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->default_settings = apply_filters( 'powerkit_social_links_widget_settings', array(
|
||||
'title' => esc_html__( 'Social Links', 'powerkit' ),
|
||||
'template' => 'inline',
|
||||
'scheme' => 'light',
|
||||
'cache' => true,
|
||||
'labels' => true,
|
||||
'titles' => true,
|
||||
'counts' => true,
|
||||
'maximum' => -1,
|
||||
'mode' => apply_filters( 'powerkit_social_links_counter_mode', 'mixed' ),
|
||||
) );
|
||||
|
||||
$widget_details = array(
|
||||
'classname' => 'powerkit_social_links_widget',
|
||||
'description' => esc_html__( 'Add a list of social links with fan counts to your sidebar.', 'powerkit' ),
|
||||
);
|
||||
parent::__construct( 'powerkit_social_links_widget', esc_html__( 'Social Links', 'powerkit' ), $widget_details );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the content for the current widget instance.
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
// Before Widget.
|
||||
echo $args['before_widget']; // XSS OK.
|
||||
?>
|
||||
|
||||
<div class="widget-body">
|
||||
<?php
|
||||
|
||||
// Title.
|
||||
if ( $params['title'] ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', wp_kses( $params['title'], 'pk-title' ), $instance, $this->id_base ) . $args['after_title']; // XSS.
|
||||
}
|
||||
|
||||
powerkit_social_links_appearance( $params );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// After Widget.
|
||||
echo $args['after_widget']; // XSS OK.
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating settings for the current widget instance.
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via
|
||||
* WP_Widget::form().
|
||||
* @param array $old_instance Old settings for this instance.
|
||||
* @return array Settings to save or bool false to cancel saving.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $new_instance;
|
||||
|
||||
// Labels.
|
||||
if ( ! isset( $instance['labels'] ) ) {
|
||||
$instance['labels'] = false;
|
||||
}
|
||||
|
||||
// Titles.
|
||||
if ( ! isset( $instance['titles'] ) ) {
|
||||
$instance['titles'] = false;
|
||||
}
|
||||
|
||||
// Counts.
|
||||
if ( ! isset( $instance['counts'] ) ) {
|
||||
$instance['counts'] = false;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$params = array_merge( $this->default_settings, $instance );
|
||||
|
||||
$templates = apply_filters( 'powerkit_social_links_templates', array() );
|
||||
$color_schemes = apply_filters( 'powerkit_social_links_color_schemes', array() );
|
||||
?>
|
||||
<!-- Title -->
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'powerkit' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $params['title'] ); ?>" /></p>
|
||||
|
||||
<!-- Labels -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'labels' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'labels' ) ); ?>" type="checkbox" <?php checked( (bool) $params['labels'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'labels' ) ); ?>"><?php esc_html_e( 'Display labels', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Titles -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'titles' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'titles' ) ); ?>" type="checkbox" <?php checked( (bool) $params['titles'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'titles' ) ); ?>"><?php esc_html_e( 'Display titles', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Сounts -->
|
||||
<p><input id="<?php echo esc_attr( $this->get_field_id( 'counts' ) ); ?>" class="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'counts' ) ); ?>" type="checkbox" <?php checked( (bool) $params['counts'] ); ?> />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'counts' ) ); ?>"><?php esc_html_e( 'Display counts', 'powerkit' ); ?></label></p>
|
||||
|
||||
<!-- Maximum Number of Social Links -->
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'maximum' ) ); ?>"><?php esc_html_e( 'Maximum number of social links:', 'powerkit' ); ?></label>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'maximum' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'maximum' ) ); ?>" type="text" value="<?php echo (int) $params['maximum']; ?>" size="3" />
|
||||
</p>
|
||||
|
||||
<p class="help">
|
||||
<?php echo esc_html__( 'Input -1 to remove the maximum limit of the social links.', 'powerkit' ); ?>
|
||||
</p>
|
||||
|
||||
<!-- Template -->
|
||||
<?php if ( count( (array) $templates ) > 1 ) : ?>
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'Template' ) ); ?>"><?php esc_html_e( 'Template:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'template' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'template' ) ); ?>" class="widefat">
|
||||
<?php
|
||||
if ( $templates ) {
|
||||
foreach ( $templates as $key => $item ) {
|
||||
if ( isset( $item['public'] ) && false === $item['public'] ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $params['template'], $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Color scheme -->
|
||||
<?php if ( count( (array) $color_schemes ) > 1 ) : ?>
|
||||
<p><label for="<?php echo esc_attr( $this->get_field_id( 'Template' ) ); ?>"><?php esc_html_e( 'Color scheme:', 'powerkit' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $this->get_field_name( 'scheme' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'scheme' ) ); ?>" class="widefat">
|
||||
<?php
|
||||
if ( $color_schemes ) {
|
||||
foreach ( $color_schemes as $key => $item ) {
|
||||
if ( isset( $item['public'] ) && false === $item['public'] ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $params['scheme'], $key ); ?>><?php echo esc_attr( $item['name'] ); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="pk-alert pk-alert-warning">
|
||||
<?php
|
||||
echo sprintf( '<a href="%2$s" target="_blank">%1$s</a>', esc_html__( 'Configure Social Links', 'powerkit' ), esc_url( powerkit_get_page_url( 'social_links' ) ) );
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Widget
|
||||
*/
|
||||
function powerkit_widget_init_social_links() {
|
||||
register_widget( 'Powerkit_Social_Links_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'powerkit_widget_init_social_links' );
|
||||
+4047
File diff suppressed because it is too large
Load Diff
+4047
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user