.appreplicaicons-css {
width: ' . get_site_option('appreplicaicons-size', 24) . 'px;
height: ' . get_site_option('appreplicaicons-size', 24) . 'px;
opacity: ' . get_site_option('appreplicaicons-opacity', 1) . ';
margin-left: ' . get_site_option('appreplicaicons-spacing-h', 3) . 'px;
margin-right: ' . get_site_option('appreplicaicons-spacing-h', 3) . 'px;
margin-top: ' . get_site_option('appreplicaicons-spacing-v', 3) . 'px;
margin-bottom: ' . get_site_option('appreplicaicons-spacing-v', 3) . 'px;
}
.appreplicaicons-css:hover { opacity: ' . get_site_option('appreplicaicons-opacity-hover', 1) . '; }
.appreplicaicons-other-css {
font-size: ' . get_site_option('appreplicaicons-other-size', 24) . 'px;
color: ' . get_site_option('appreplicaicons-other-color') . ';
margin-left: ' . get_site_option('appreplicaicons-other-spacing-h', 3) . 'px;
margin-right: ' . get_site_option('appreplicaicons-other-spacing-h', 3) . 'px;
margin-top: ' . get_site_option('appreplicaicons-other-spacing-v', 3) . 'px;
margin-bottom: ' . get_site_option('appreplicaicons-other-spacing-v', 3) . 'px;
text-decoration: none !important;
}
a.appreplicaicons-other-css:link { color: ' . get_site_option('appreplicaicons-other-color') . '; text-decoration: none !important; }
a.appreplicaicons-other-css:visited { color: ' . get_site_option('appreplicaicons-other-color') . '; text-decoration: none !important; }
a.appreplicaicons-other-css:hover { color: ' . get_site_option('appreplicaicons-other-color-hover') . '; text-decoration: none !important; }
';
# Create an array for items to output
include ("appreplica-social-icons-list.php");
$i = 0;
foreach ($appreplicaicons as $value) {
$iconName = 'appreplicaicons_icon_' . $value[0] . '_' . $value[1];
if (get_site_option($iconName) == 1) {
$icon[$i]['Url'] = $iconName . '_url';
$icon[$i]['tooltip'] = $iconName . '_text';
$icon[$i]['target'] = $iconName . '_target';
$icon[$i]['order'] = $iconName . '_order';
$icon[$i]['name'] = $value[0];
$icon[$i]['folder'] = $value[1];
$icon[$i]['UrlVal'] = get_site_option($icon[$i]['Url']);
$icon[$i]['tooltipVal'] = get_site_option($icon[$i]['tooltip']);
$icon[$i]['targetVal'] = get_site_option($icon[$i]['target'],0);
$icon[$i]['orderVal'] = get_site_option($icon[$i]['order'],0);
$i++;
}
}
// add custom icons to array
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$table_name = $wpdb->prefix . "appreplica_social_icons";
$sql = "SELECT * FROM " . $table_name . " WHERE 1";
$iconList = $wpdb->get_results($sql);
foreach($iconList as $item) {
$iconName = 'appreplicaicons_icon_custom_' . $item->id;
$icon[$i]['Url'] = $iconName . '_url';
$icon[$i]['tooltip'] = $iconName . '_text';
$icon[$i]['target'] = $iconName . '_target';
$icon[$i]['order'] = $iconName . '_order';
$icon[$i]['name'] = $item->ar_title;
$icon[$i]['folder'] = 999; // custom icon flag
$icon[$i]['UrlVal'] = get_site_option($icon[$i]['Url']);
$icon[$i]['ImgUrl'] = $item->ar_imageurl;
$icon[$i]['tooltipVal'] = get_site_option($icon[$i]['tooltip']);
$icon[$i]['targetVal'] = get_site_option($icon[$i]['target'],0);
$icon[$i]['orderVal'] = get_site_option($icon[$i]['order'],0);
$i++;
}
// sort according to custom order
foreach ($icon as $key => $row) {
$order[$key] = $row['orderVal'];
}
array_multisort($order, SORT_ASC, $icon);
# Output icons List
for ($j = 0 ; $j < count($icon) ; $j++) {
if ($icon[$j]['targetVal'] == 1) { $target = '_blank'; } else { $target = '_self'; }
# code
if ($icon[$j]['folder'] <= 3) {
$code .= '';
$code .= '
';
$code .= '';
}
if ($icon[$j]['folder'] == 99) {
$code .= '';
$code .= '';
$code .= '';
}
if ($icon[$j]['folder'] == 999) {
$code .= '';
$code .= '';
$code .= '';
}
}
# Return code
return $code;
}
# Create appreplicaicons settings menu for admin
add_action( 'admin_menu', 'appreplicaicons_create_menu' );
add_action( 'network_admin_menu', 'appreplicaicons_network_admin_create_menu' );
# Create link to plugin options page from plugins list
function appreplicaicons_plugin_add_settings_link( $links ) {
$settings_link = 'Settings';
array_push( $links, $settings_link );
return $links;
}
$appreplicaicons_plugin_basename = plugin_basename( __FILE__ );
add_filter( 'plugin_action_links_' . $appreplicaicons_plugin_basename, 'appreplicaicons_plugin_add_settings_link' );
# Create new top level menu for sites
function appreplicaicons_create_menu() {
add_menu_page('Appreplica Options', 'Icons', 'install_plugins', 'appreplicaicons_settings_page', 'appreplicaicons_settings_page');
}
# Create new top level menu for network admin
function appreplicaicons_network_admin_create_menu() {
add_menu_page('Appreplica Options', 'Icons', 'manage_options', 'appreplicaicons_settings_page', 'appreplicaicons_settings_page');
}
function appreplicaicons_update_option($name, $value) {
return is_multisite() ? update_site_option($name, $value) : update_option($name, $value);
}
# Define widget
class AppreplicaIcons_Widget extends WP_Widget {
# Register widget with WordPress
function __construct() {
parent::__construct(
'appreplicaicons_widget', // Base ID
'Appreplica Social Icons', // Name
array( 'description' => __( 'Add social icons to your widgets sections' ), ) // Args
);
}
# Frontend display of widget
public function widget( $args, $instance ) {
extract($args);
$title = apply_filters( 'widget_title', $instance['title'] );
echo $before_widget;
if (!empty($title)) { echo $before_title . $title . $after_title; }
echo embed_appreplicaicons();
echo $after_widget;
}
# Backend widget form.
public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' );
?>
prefix . "appreplica_social_icons"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql2 = "CREATE TABLE `$table_name` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `ar_title` VARCHAR(255) NULL, `ar_imageurl` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql2); } } register_activation_hook(__FILE__,'appreplicaicons_database_setup'); function appreplicaicons_settings_page() { ?>
How do I get started?
The shortcode doesn't work when I add it to the Text Widget?Some themes are setup by default to not parse the text widget for shortcodes, resulting in only the shortcode text to appear instead of the icons. To fix this, you must enable shortcodes for the text widget by adding the following code to your theme's function.php file. In most cases, you can simply use the Appearance > Editor option to add this line without having to resort to FTP or other means of file access.add_filter('widget_text', 'do_shortcode');
What's the purpose of this plugin?This free plugin lets you add custom icons for major social and media content websites to the widgets sections of your WordPress powered websites. It's designed primarily for the users of our Appreplica Plugin in order to create icons in their widget sections linking to their embedded content pages, but it can also be used by others. Each icon can be linked to any relative or external URL of your choosing, and you can customize both the size and its colors. |