| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Weather Effect |
| 4 |
Plugin URI: https://awplife.com/ |
| 5 |
Description: This is Weather Effect Widget. |
| 6 |
Version: 1.5.6 |
| 7 |
Author: A WP Life |
| 8 |
Author URI: https://awplife.com/ |
| 9 |
License: GPLv2 or later |
| 10 |
Text Domain: weather-effect |
| 11 |
Domain Path: /languages |
| 12 |
|
| 13 |
Weather Effect is free software: you can redistribute it and/or modify |
| 14 |
it under the terms of the GNU General Public License as published by |
| 15 |
the Free Software Foundation, either version 2 of the License, or |
| 16 |
any later version. |
| 17 |
|
| 18 |
Weather Effect is distributed in the hope that it will be useful, |
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
GNU General Public License for more details. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License |
| 24 |
along with User Registration. If not, see https://www.gnu.org/licenses/gpl-2.0.html. |
| 25 |
*/ |
| 26 |
|
| 27 |
define( 'WE_PLUGIN_PATH', plugin_dir_url( __FILE__ ) ); |
| 28 |
define("WEP_PLUGIN_DIR_PATH", plugin_dir_path(__FILE__)); |
| 29 |
|
| 30 |
// Plugin Text Domain |
| 31 |
define( 'WE_TXTD', 'weather-effect' ); |
| 32 |
|
| 33 |
// Load text domain |
| 34 |
add_action( 'plugins_loaded', 'WE_load_textdomain' ); |
| 35 |
|
| 36 |
function WE_load_textdomain() { |
| 37 |
load_plugin_textdomain( 'weather-effect', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 38 |
} |
| 39 |
|
| 40 |
// Default settings |
| 41 |
function weather_effect_default_settings() { |
| 42 |
$default_settings = array( |
| 43 |
'enable_weather_effect' => 1, |
| 44 |
); |
| 45 |
|
| 46 |
if ( get_option( 'weather_effect_settings' ) === false ) { |
| 47 |
add_option( 'weather_effect_settings', $default_settings ); |
| 48 |
} |
| 49 |
} |
| 50 |
register_activation_hook( __FILE__, 'weather_effect_default_settings' ); |
| 51 |
|
| 52 |
// Enqueue necessary scripts |
| 53 |
function awplife_we_enqueue_scripts() { |
| 54 |
wp_enqueue_script( 'jquery' ); |
| 55 |
} |
| 56 |
add_action( 'wp_enqueue_scripts', 'awplife_we_enqueue_scripts' ); |
| 57 |
|
| 58 |
// Weather effect premium setting page |
| 59 |
if (file_exists(WEP_PLUGIN_DIR_PATH . 'settings.php')) { |
| 60 |
require_once WEP_PLUGIN_DIR_PATH . 'settings.php'; |
| 61 |
} |
| 62 |
|
| 63 |
function awplife_we_scripts_load_in_head() { |
| 64 |
wp_enqueue_script( 'jquery' ); |
| 65 |
wp_enqueue_script( 'awplife-we-snow-christmas-snow-js', WE_PLUGIN_PATH . 'assets/js/christmas-snow/christmas-snow.js' ); |
| 66 |
wp_enqueue_script( 'awplife-we-snow-snow-falling-js', WE_PLUGIN_PATH . 'assets/js/snow-falling/snow-falling.js' ); |
| 67 |
wp_enqueue_script( 'awplife-we-snow-snowfall-master-js', WE_PLUGIN_PATH . 'assets/js/snowfall-master/snowfall-master.min.js', array( 'jquery' ), '', true ); |
| 68 |
|
| 69 |
$weather_effect_settings = get_option( 'weather_effect_settings' ); |
| 70 |
$enable_weather_effect = isset( $weather_effect_settings['enable_weather_effect'] ) ? $weather_effect_settings['enable_weather_effect'] : 1; |
| 71 |
|
| 72 |
// Check if weather effect is enabled |
| 73 |
if ( $enable_weather_effect == 1 ) { |
| 74 |
require_once 'output.php'; |
| 75 |
} |
| 76 |
} |
| 77 |
add_action( 'wp_head', 'awplife_we_scripts_load_in_head' ); |
| 78 |
|
| 79 |
// Ensure WordPress is fully loaded before using wp_get_current_user |
| 80 |
add_action( 'init', 'awplife_verify_user' ); |
| 81 |
|
| 82 |
function awplife_verify_user() { |
| 83 |
if ( function_exists( 'wp_get_current_user' ) ) { |
| 84 |
$user = wp_get_current_user(); |
| 85 |
// You can add your logic here using $user |
| 86 |
} |
| 87 |
}?> |
| 88 |
|