' . __('Settings', 'all-social-share') . '';
array_unshift($links, $settings_link);
return $links;
}
public function assp_add_social_share_buttons($content) {
$options = get_option('assp_social_share_options');
$feature_enabled = isset($options['assp_social_share_field_toggle']) && $options['assp_social_share_field_toggle'] == 1;
$display_on_mobile = $options['assp_social_share_display_on_mobile'];
if ($feature_enabled) {
$post_type = get_post_type(); // Get the current post type
if (isset($options['post_types'][$post_type]) && $options['post_types'][$post_type] == 1) {
$social_buttons = $this->assp_generate_social_buttons();
// Check if backend selection enables display on mobile
$display_on_mobile = isset($options['assp_social_share_display_on_mobile']) ? $options['assp_social_share_display_on_mobile'] : false;
// Check if it's a mobile device
$is_mobile = wp_is_mobile();
// Check if display is enabled on mobile and it's a mobile device, or if it's not a mobile device
if (($display_on_mobile && $is_mobile) || !$is_mobile) {
// Add a class based on the selected position
$position_class = isset($options['assp_social_share_position']) ? ' position-' . $options['assp_social_share_position'] : '';
$content .= '
';
foreach ($social_buttons as $button_key => $button_data) {
if (!in_array($button_key, $selected_val)) {
continue; // ❌ Skip buttons not in the selected list
}
if ($button_key === 'copy_link') {
$buttons_html .= '';
$buttons_html .= '';
$buttons_html .= '';
} else {
$buttons_html .= '';
$buttons_html .= '';
$buttons_html .= '';
}
}
$buttons_html .= '
';
$buttons_html .= '
';
return $buttons_html;
}
public function assp_enqueue_styles() {
if ( ! wp_script_is('jquery', 'enqueued') ) {
wp_enqueue_script('jquery');
}
wp_enqueue_script('assp-custom-js', plugins_url('js/custom.js', __FILE__), array('jquery'), '1.0.0', true);
wp_enqueue_style('assp-font-awesome', plugins_url('css/all.min.css', __FILE__), array(), '6.5.2');
//wp_enqueue_style( 'assp-font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css', array(), '6.5.2' );
wp_enqueue_style('assp-social-share-styles', plugins_url('css/social-share-styles.css', __FILE__), array('assp-font-awesome'), '1.0.0');
}
public function assp_add_admin_menu() {
add_menu_page(
__('All Social Share', 'assp-social-share'), // Page title
__('All Social Share', 'assp-social-share'), // Menu title
'manage_options', // Capability
'assp-social-share', // Menu slug
array($this, 'assp_display_settings_page'), // Function
'dashicons-share', // Icon URL
6 // Position
);
}
public function assp_settings_init() {
// Register a new setting for "my_social_share" page.
register_setting('assp_social_share', 'assp_social_share_options');
// Register a new section in the "my_social_share" page.
add_settings_section('assp_social_share_section_developers', __('', 'assp-social-share'), array($this, 'assp_social_share_section_callback'), 'assp_social_share');
// Register a new field in the "my_social_share_section_developers" section, inside the "my_social_share" page.
add_settings_field(
'assp_social_share_field_toggle', // As used in the 'id' attribute of tags.
__('Enable Plugin?', 'assp-social-share'), // Title.
array($this, 'assp_social_share_field_toggle_render'), // Callback function.
'assp_social_share', // Page on which to add this field.
'assp_social_share_section_developers' // Section in which to add this field.
);
add_settings_field(
'assp_social_share_options', // As used in the 'id' attribute of tags.
__('Where do you want to display?', 'assp-social-share'), // Title.
array($this, 'assp_social_share_section_render'), // Callback function.
'assp_social_share', // Page on which to add this field.
'assp_social_share_section_developers' // Section in which to add this field.
);
add_settings_field(
'assp_social_share_position', // As used in the 'id' attribute of tags.
__('Which place do you want display?', 'assp-social-share'), // Title.
array($this, 'assp_social_share_section_position_rendor'), // Callback function.
'assp_social_share', // Page on which to add this field.
'assp_social_share_section_developers' // Section in which to add this field.
);
add_settings_field(
'assp_social_share_display_on_mobile', // As used in the 'id' attribute of tags.
__('Need display on mobile?', 'assp-social-share'), // Title.
array($this, 'assp_social_share_section_mobile_rendor'), // Callback function.
'assp_social_share', // Page on which to add this field.
'assp_social_share_section_developers' // Section in which to add this field.
);
add_settings_field(
'assp_social_share_color', // As used in the 'id' attribute of tags.
__('Set custom color for social icons', 'assp-social-share'), // Title.
array($this, 'assp_assp_social_share_color_rendor'), // Callback function.
'assp_social_share', // Page on which to add this field.
'assp_social_share_section_developers' // Section in which to add this field.
);
// Register a new section in the "advanced" page.
register_setting('assp_social_share_advance', 'assp_social_share_advance_options');
add_settings_section('assp_social_share_section_advanced',
__('', 'assp-social-share'),
array($this, 'assp_social_share_section_advanced_callback'),
'assp_social_share_advance'
);
add_settings_field(
'assp_social_share_display_selected_icons', // As used in the 'id' attribute of tags.
__('How many options need to display?', 'assp-social-share'), // Title.
array($this, 'assp_social_share_selected_icons_rendor'), // Callback function.
'assp_social_share_advance', // Page on which to add this field.
'assp_social_share_section_advanced' // Section in which to add this field.
);
}
public function assp_social_share_section_advanced_callback(){ }
public function assp_social_share_selected_icons_rendor() {
$options = get_option('assp_social_share_advance_options');
$selected_icons = isset($options['assp_social_share_display_selected_icons']) ? $options['assp_social_share_display_selected_icons'] : array();
$social_media_platforms = array(
'copy_link' => 'Copy Link Button',
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
'pinterest' => 'Pinterest',
'whatsapp' => 'Whatsapp',
'mail' => 'Mail',
'gmail' => 'G-Mail',
'telegram' => 'Telegram',
'google-plus' => 'Google+',
'print' => 'Print',
'reddit' => 'Reddit',
'tumblr' => 'Tumblr',
'flipboard' => 'Flipboard',
'pocket' => 'Pocket'
);
foreach ($social_media_platforms as $platform_key => $platform_name) {
$checked = in_array($platform_key, $selected_icons) ? 'checked="checked"' : '';
?>