wp-social.php
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 | /* |
| 4 | * Plugin Name: Wp Social |
| 5 | * Plugin URI: https://wpmet.com/ |
| 6 | * Description: Wp Social Login / Social Sharing / Social Counter System for Facebook, Google, Twitter, Linkedin, Dribble, Pinterest, Wordpress, Instagram, GitHub, Vkontakte, Reddit and more providers. |
| 7 | * Author: Wpmet |
| 8 | * Version: 1.3.6 |
| 9 | * Author URI: https://wpmet.com/ |
| 10 | * Text Domain: wp-social |
| 11 | * License: GPL2+ |
| 12 | * Domain Path: /languages/ |
| 13 | **/ |
| 14 | |
| 15 | define('WSLU_VERSION', '1.3.6'); |
| 16 | define('WSLU_VERSION_PREVIOUS_STABLE_VERSION', '1.3.5'); |
| 17 | |
| 18 | define("WSLU_LOGIN_PLUGIN", plugin_dir_path(__FILE__)); |
| 19 | define("WSLU_LOGIN_PLUGIN_URL", plugin_dir_url(__FILE__)); |
| 20 | |
| 21 | |
| 22 | require(WSLU_LOGIN_PLUGIN . 'autoload.php'); |
| 23 | /** |
| 24 | * Load Text Domain |
| 25 | */ |
| 26 | if( ! function_exists('wslu_social_init')) : |
| 27 | function wslu_social_init() { |
| 28 | load_plugin_textdomain('wp-social', false, dirname(plugin_basename(__FILE__)) . '/languages'); |
| 29 | |
| 30 | if(file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) { |
| 31 | WpSocialXs\Elementor\Elements::instance()->_init(); |
| 32 | } |
| 33 | |
| 34 | do_action('wslu_social/plugin_loaded'); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | add_action('plugins_loaded', 'wslu_social_init', 118); |
| 39 | endif; |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Active Plugin |
| 44 | */ |
| 45 | if( ! function_exists('xs_social_plugin_activate')) : |
| 46 | function xs_social_plugin_activate() { |
| 47 | $counter = New \XsSocialCount\Counter(false); |
| 48 | $counter->xs_counter_defalut_providers(); |
| 49 | } |
| 50 | |
| 51 | register_activation_hook(__FILE__, 'xs_social_plugin_activate'); |
| 52 | |
| 53 | // custom function added |
| 54 | if(file_exists(WSLU_LOGIN_PLUGIN . 'inc/custom-function.php')) { |
| 55 | include(WSLU_LOGIN_PLUGIN . 'inc/custom-function.php'); |
| 56 | } |
| 57 | endif; |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | if(!function_exists('wp_social_admin_enqueue')) { |
| 65 | |
| 66 | function wp_social_admin_enqueue() { |
| 67 | |
| 68 | $screen = get_current_screen(); |
| 69 | |
| 70 | wp_register_script( 'wp_social_footer', WSLU_LOGIN_PLUGIN_URL. 'assets/js/hearbeat_all.js', ['jquery', 'heartbeat'], '1.1.1', true ); |
| 71 | wp_enqueue_script('wp_social_footer'); |
| 72 | |
| 73 | if($screen->id == 'wp-social_page_wslu_data_migration') { |
| 74 | wp_register_script( 'wp_social_footer2', WSLU_LOGIN_PLUGIN_URL. 'assets/js/heartbeat_data_conversion.js', ['jquery', 'heartbeat'], '1.1.1', true ); |
| 75 | wp_enqueue_script('wp_social_footer2'); |
| 76 | } |
| 77 | |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | function xs_heartbeat_settings( $settings ) { |
| 82 | |
| 83 | $settings['interval'] = 15; //Anything between 15-120 |
| 84 | //$settings['autostart'] = false; |
| 85 | |
| 86 | return $settings; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | function xs_social_heartbeat_received($response, $data) { |
| 91 | |
| 92 | $response['client_push']['log'][] = 'heartbeat received...'; |
| 93 | |
| 94 | if(isset($data['global'])) { |
| 95 | |
| 96 | $response['client_push']['global'][] = 'global data received and processed.... global = '.$data['global']; |
| 97 | } |
| 98 | |
| 99 | if(isset($data['gd_client'])) { |
| 100 | |
| 101 | $response['client_push']['global'][] = 'global data received and processed.... gd_client = '.$data['gd_client']; |
| 102 | } |
| 103 | |
| 104 | if(isset($data['pd_client'])) { |
| 105 | |
| 106 | $response['client_push']['page'][] = 'page data received and processed.... pd_client = '.$data['pd_client']; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | if(isset($data['requesting_page']) && $data['requesting_page'] == 'wp-social_page_wslu_data_migration') { |
| 111 | |
| 112 | $response['client_push']['page'][] = '.............................................................'; |
| 113 | |
| 114 | if(isset($data['page']['wp-social_page_wslu_data_migration'])) { |
| 115 | |
| 116 | $response['client_push']['page'][] = 'Data received from specific page and processing ...... == '.$data['page']['wp-social_page_wslu_data_migration']; |
| 117 | |
| 118 | } else { |
| 119 | |
| 120 | $response['client_push']['page'][] = 'Supposed to have some data from specific page!!!'; |
| 121 | } |
| 122 | |
| 123 | } |
| 124 | |
| 125 | $response['client_push']['log'][] = $data; |
| 126 | |
| 127 | |
| 128 | return $response; |
| 129 | } |
| 130 | |
| 131 | function send_data_to_heartbeat( $data, $screen_id ) { |
| 132 | |
| 133 | $data['server_push'][] = 'Some notification from heartbeat send'; |
| 134 | |
| 135 | return $data; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | add_filter( 'heartbeat_settings', 'xs_heartbeat_settings' ); |
| 140 | |
| 141 | add_action("admin_enqueue_scripts", "wp_social_admin_enqueue"); |
| 142 | add_filter('heartbeat_received', 'xs_social_heartbeat_received', 10, 2); |
| 143 | //add_filter( 'heartbeat_send', 'send_data_to_heartbeat', 10, 2 ); |
| 144 |