File: /www/wwwroot/pulitocucito.it/wp-content/plugins/laundry-helper/laundry-helper.php
<?php
/*
Plugin Name: Laundry Helper
Plugin URI: http://smartdatasoft.com/
Description: Helping for the Laundry theme.
Author: SmartDataSoft
Version: 3.5
Author URI: http://smartdatasoft.com/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
/**
* The main plugin class
*/
final class LaundryHelper {
/**
* Plugin version
*
* @var string
*/
const version = '1.0';
/**
* Plugin Version
*
* @since 1.2.0
* @var string The plugin version.
*/
const VERSION = '1.2.0';
/**
* Minimum Elementor Version
*
* @since 1.2.0
* @var string Minimum Elementor version required to run the plugin.
*/
const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
/**
* Minimum PHP Version
*
* @since 1.2.0
* @var string Minimum PHP version required to run the plugin.
*/
const MINIMUM_PHP_VERSION = '7.0';
/**
* Constructor
*
* @since 1.0.0
* @access public
*/
/**
* Class construcotr
*/
private function __construct() {
$this->define_constants();
register_activation_hook( __FILE__, array( $this, 'activate' ) );
add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
}
/**
* Initializes a singleton instance
*
* @return \Laundry
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Define the required plugin constants
*
* @return void
*/
public function define_constants() {
define( 'LAUNDRY_HELPER_VERSION', self::version );
define( 'LAUNDRY_HELPER_FILE', __FILE__ );
define( 'LAUNDRY_HELPER_PATH', __DIR__ );
define( 'LAUNDRY_HELPER_URL', plugins_url( '', LAUNDRY_HELPER_FILE ) );
define( 'LAUNDRY_HELPER_ASSETS', LAUNDRY_HELPER_URL . '/assets' );
define( 'LAUNDRY_HELPER_THEME_URI', get_template_directory_uri() );
define( 'LAUNDRY_HELPER_IMG_URL', LAUNDRY_HELPER_THEME_URI . '/images' );
$theme = wp_get_theme();
define( 'THEME_VERSION_CORE', $theme->Version );
define( 'LAUNDRY_HELPER_DIR', dirname( __FILE__ ) . '/' );
}
/**
* Initialize the plugin
*
* @return void
*/
public function init_plugin() {
load_plugin_textdomain( 'laundry-helper', false, basename( dirname( __FILE__ ) ) . '/languages' );
new \Laundry\Helper\Posttype();
new \Laundry\Helper\Hooks();
if ( class_exists( 'Vc_Manager' ) ) {
new \Laundry\Helper\WPBakery();
}
new \Laundry\Helper\Widgets();
new \Laundry\Helper\Elementor();
// sidebar generator
new \Laundry\Helper\SidebarGenerator();
if ( is_admin() ) {
new \Laundry\Helper\Admin();
}
}
public function checkElementor() {
// Check if Elementor installed and activated
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
return;
}
// Check for required Elementor version
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
return;
}
// Check for required PHP version
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
return;
}
}
/**
* Do stuff upon plugin activation
*
* @return void
*/
public function activate() {
// $installer = new Laundry\Helper\Installer();
// $installer->run();
}
}
/**
* Initializes the main plugin
*
* @return \LaundryHelper
*/
function LaundryHelper() {
return LaundryHelper::init();
}
// kick-off the plugin
LaundryHelper();
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
function laundry_social_share_func() {
global $post;
?>
<ul class="tt-social">
<li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://twitter.com/home?status=<?php echo urlencode( get_the_title() ); ?>-<?php echo esc_url( get_permalink( $post ) ); ?>" target="_blank" class="icons-733635"></a></li>
<li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo esc_url( get_permalink( $post ) ); ?>" target="_blank" class="icons-59439"></a></li>
<li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo esc_url( get_permalink( $post ) ); ?>" target="_blank" class="icons-2111532"></a></li>
<li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.instagram.com/p/B8Jp8UbAHmd/?utm_source=<?php echo esc_url( get_permalink( $post ) ); ?>"target="_blank" class="icons-733614"></a></li>
</ul>
<?php
}
add_action( 'laundry_social_share', 'laundry_social_share_func' );
// Hook called when the plugin is activated.
add_action( 'plugins_loaded', 'function_elem_cpt_support' );
/**
* This function is called on plugin activation.
*
* @return void
*/
/**
* Function_elem_cpt_support adds cpt support for elementor.
*
* @return void
*/
function function_elem_cpt_support() {
$cpt_support = get_option( 'elementor_cpt_support' );
if ( ! $cpt_support ) {
// First check if the option is not available already in the database. It not then create the array with all default post types including yours and save the settings.
$cpt_support = array( 'page', 'post', 'laundry_services' );
update_option( 'elementor_cpt_support', $cpt_support );
} elseif ( ! in_array( 'laundry_services', $cpt_support ) ) {
// If the option is available then just append the array and update the settings.
$cpt_support[] = 'laundry_services';
update_option( 'elementor_cpt_support', $cpt_support );
}
}