' . __('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 .= '
' . $social_buttons . '
'; } } } return $content; } public function assp_enqueue_admin_styles($hook) { // Enqueue WP color picker CSS & JS wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); // Your admin CSS wp_enqueue_style('assp-admin-toggle-button-styles', plugins_url('css/admin-styles.css', __FILE__)); // Inline JS to initialize color picker $inline_js = << array( 'url' => 'javascript:void(0);', 'class' => 'fas fa-link', 'id' => 'assp-copy-link-btn', 'data' => esc_url($permalink), ), 'facebook' => array( 'url' => 'https://www.facebook.com/sharer/sharer.php?u=' . esc_url($permalink), 'class' => 'fab fa-facebook-square', ), 'twitter' => array( 'url' => 'https://twitter.com/intent/tweet?url=' . esc_url($permalink) . '&text=' . esc_attr($title), 'class' => 'fab fa-twitter', ), 'linkedin' => array( 'url' => 'https://www.linkedin.com/shareArticle?url=' . esc_url($permalink) . '&title=' . esc_attr($title), 'class' => 'fab fa-linkedin', ), 'pinterest' => array( 'url' => 'https://pinterest.com/pin/create/button/?url=' . esc_url($permalink) . '&media=' . esc_url($thumbnail_url) . '&description=' . esc_attr($title), 'class' => 'fab fa-pinterest', ), 'whatsapp' => array( 'url' => 'https://api.whatsapp.com/send?text=' . esc_attr($title) . ' ' . esc_url($permalink), 'class' => 'fab fa-whatsapp', ), 'email' => array( 'url' => 'mailto:?subject=' . esc_attr($title) . '&body=' . esc_url($permalink), 'class' => 'fas fa-envelope', ), 'gmail' => array( 'url' => 'https://mail.google.com/mail/u/0/?view=cm&fs=1&to&su=' . esc_attr($title) . '&body=' . esc_url($permalink), 'class' => 'fas fa-envelope-square', ), 'telegram' => array( 'url' => 'https://t.me/share/url?url=' . esc_url($permalink) . '&text=' . esc_attr($title), 'class' => 'fab fa-telegram', ), 'google_plus' => array( 'url' => 'https://plus.google.com/share?url=' . esc_url($permalink), 'class' => 'fab fa-google-plus', ), 'print' => array( 'url' => 'javascript:window.print()', 'class' => 'fas fa-print', ), 'reddit' => array( 'url' => 'https://www.reddit.com/submit?url=' . urlencode( get_permalink() ), 'class' => 'fab fa-reddit-alien', ), 'tumblr' => array( 'url' => 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=' . urlencode( get_permalink() ), 'class' => 'fab fa-tumblr', ), 'flipboard' => array( 'url' => 'https://share.flipboard.com/bookmarklet/popout?v=2&url=' . urlencode( get_permalink() ), 'class' => 'fab fa-flipboard', ), 'pocket' => array( 'url' => 'https://getpocket.com/save?url=' . urlencode( get_permalink() ), 'class' => 'fab fa-get-pocket', ), ); $buttons_html = '
'; 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"' : ''; ?> true], 'objects'); foreach ($post_types as $post_type) { if ($post_type->name !== 'attachment') { $checked_value = isset($options['post_types'][$post_type->name]) ? checked($options['post_types'][$post_type->name], 1, false) : ''; ?>
labels->name); ?>