File: /var/www/bharti-foundation.stgviitor.com/wp-content/plugins/lifeline-plugin/lifeline-plugin.php
<?php
/**
* Plugin Name: LifeLine Plugin
* Plugin URI: https://themes.webinane.com/wp/lifeline/
* Description: An non-profit toolkit that help to execute the lifeline WordPress theme by Webinane.
* Version: 2.3
* Author: Webinane
* Author URI: https://webinane.com
* Text Domain: lifeline-plugin
* Domain Path: /languages
*
* @package Lifeline
*/
namespace Lifeline\Plugin;
use Lifeline\Plugin\Libraries;
class LifeLine_PL_Loader {
public static $instance;
public function __construct() {
defined( 'LIFELINE_PL_PATH' ) || define( 'LIFELINE_PL_PATH', plugin_dir_path( __FILE__ ) );
defined( 'LIFELINE_PL_URL' ) || define( 'LIFELINE_PL_URL', plugin_dir_url( __FILE__ ) );
self::includes();
self::autoload();
self::setup();
}
static function includes() {
require_once LIFELINE_PL_PATH . 'includes/Libraries/ReduxApiMetaboxes.php';
require_once LIFELINE_PL_PATH . 'includes/Libraries/ClassLoader.php';
require_once LIFELINE_PL_PATH . 'includes/Functions.php';
require_once LIFELINE_PL_PATH . 'includes/FileCrop.php';
}
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
static function setup() {
\Lifeline\Plugin\Classes\Setup::boot();
add_filter( 'post_gallery', 'lifeline_post_gallery', 60, 2 );
//add_action( 'after_setup_theme', array( __CLASS__, 'migrate' ), 200 );
}
static function autoload() {
// autoload_psr4.php @generated by Composer
$includeDir = LIFELINE_PL_PATH . 'includes'; // phpcs:ignore WordPress
$psr = array(
'Lifeline\\Plugin\\' => array( $includeDir ), // phpcs:ignore WordPress
);
$class_loader = new Libraries\ClassLoader;
foreach ( $psr as $prefix => $paths ) {
$class_loader->setPsr4( $prefix, $paths );
}
$class_loader->register();
}
static function migrate() {
//delete_option('lifeline_migrate');exit;
$data = get_option( 'lifeline_migrate' );
if ( ! $data ) {
add_action(
'admin_notices',
function() {
?>
<div class="notice notice-success is-dismissible">
<p><?php _e( 'Lifleine 2 need the database upgradation.', 'lifeline-plugin' ); ?></p>
<a class="button-primary" href="<?php echo esc_url( admin_url( '/' ) . '?lifeline_update=true' ); ?>"><?php _e( 'UPDATE NOW', 'lifeline-plugin' ); ?></a>
</div>
<?php
}
);
self::team_upgrade();
}
}
static function team_upgrade() {
if ( lifeline_get( $_GET, 'lifeline_update' ) ) {
$post = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'lif_team',
)
);
if ( $post ) {
foreach ( $post as $p ) {
$updat_meta_set = array(
'redux_repeater_data' => array(),
'icon' => array(),
'link' => array(),
'bg_color' => array(),
'text_color' => array(),
);
$meta = get_post_meta( 84, 'team_social_media', true );
if ( ! lifeline_get( $meta, 'redux_repeater_data' ) ) {
foreach ( $meta as $icon ) {
$icon = json_decode( urldecode( lifeline_get( $icon, 'data' ) ), true );
if ($icon['enable'] == true) {
$icon_class = lifeline_get($icon, 'icon');
// Check if the icon already has a prefix
if (strpos($icon_class, 'fa-') === 0) {
$updat_meta_set['icon'][] = $icon_class; // Use as-is if a prefix exists
} else {
$updat_meta_set['icon'][] = 'fab ' . $icon_class; // Default to 'fab'
}
$updat_meta_set['link'][] = lifeline_get($icon, 'url');
$updat_meta_set['bg_color'][] = lifeline_get($icon, 'background');
$updat_meta_set['text_color'][] = lifeline_get($icon, 'color');
$updat_meta_set['redux_repeater_data'][] = array('title' => '');
}
}
update_post_meta( $p->ID, 'team_social_media', $updat_meta_set );
}
}
}
}
update_option( 'lifeline_migrate', true );
}
}
add_action(
'lifeline/theme/loaded',
function () {
new LifeLine_PL_Loader();
}
);
add_action(
'plugins_loaded',
function () {
load_plugin_textdomain( 'lifeline-plugin', false, basename( plugin_basename( __FILE__ ) ) . '/languages/' );
}
);
register_activation_hook(
__FILE__,
function () {
global $wpdb;
global $charset_collate;
$table_name = $wpdb->prefix . 'lifeline_volunteer';
$sql_create_table = "CREATE TABLE IF NOT EXISTS $table_name (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) DEFAULT NULL,
email varchar(50) DEFAULT NULL,
number varchar(50) DEFAULT NULL,
date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
status varchar(45) DEFAULT NULL,
form_data LONGTEXT DEFAULT NULL,
form_header varchar(250) DEFAULT NULL,
form_subject varchar(250) DEFAULT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql_create_table );
}
);