File: /home/primrwxj/thepassiveincomeideas.com/wp-content/plugins/wpauto-pro/wpauto-pro.php
<?php
/**
* Plugin Name: WPAuto Pro
* Plugin URI: https://aipublish.com
* Description: Automate content using OpenAI, ChatGPT, Gemini, DeepSeek, Grok, Claude, feeds, and 300+ OpenRouter AI models via official APIs.
* Version: 5.5.1
* Author: AI Publish
* Author URI: https://aipublish.com
* Text Domain: wpauto-pro
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
register_activation_hook( __FILE__, 'wpauto_pro_activation' );
function wpauto_pro_activation() {
add_option( 'wpauto_pro_status', 'activated' );
}
register_deactivation_hook( __FILE__, 'wpauto_pro_deactivation' );
function wpauto_pro_deactivation() {
delete_option( 'wpauto_pro_status' );
}
if( ! class_exists('PM_WPAuto') ) {
define( 'WPAUTO_FILE', __FILE__ );
define( 'WPAUTO_DIR', plugin_dir_path( __FILE__ ) );
define( 'WPAUTO_URL', plugin_dir_url( __FILE__ ) );
define( 'WPAUTO_BASENAME', plugin_basename( __FILE__ ) );
define( 'WPAUTO_VERSION', '5.4.1' );
class PM_WPAuto {
public static $instance = null;
public static $version = '5.4.1';
public function __construct() {
// clear campaign lock
//delete_transient( 'wpauto_campaign_lock' );
// setup page
add_action( 'init', [ $this, 'addon_setup' ] );
// Check elementor status
//add_action( 'plugins_loaded', array( $this, 'wpauto_fun' ), 99 );
$this->wpauto_fun();
// cron register deactivation
register_deactivation_hook( WPAUTO_FILE, [ $this, 'wpauto_clear_scheduled_event' ] );
}
public function wpauto_fun() {
//if( !$this->is_compatible() ) return false;
// deprecated functions
$this->deprecated_con();
// Activation hook
register_activation_hook( __FILE__, array( $this, 'wpauto_activation' ) );
// Init action
add_action( 'admin_init', array( $this, 'wpauto_activation_redirect' ) );
// license manager
$this->license_manager();
// init plugin process
$this->init();
// seo plugin
$this->seo_plugin();
// other plugin supports
$this->supports();
}
public function check_plugin_installed( $plugin ) {
if (!function_exists('get_plugins')) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
return isset($plugins[$plugin]);
}
public function check_plugin_active( $plugin ) {
if ( !function_exists( 'is_plugin_active' ) ){
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}
return is_plugin_active( $plugin );
}
public function admin_notice_wpauto_free_req() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$plugin = 'wpauto/wpauto.php';
$pro_text = esc_html__( 'WPAuto Pro', 'ai-addons' );
$free_text = esc_html__( 'WPAuto', 'ai-addons' );
$message = $btn_txt = $activation_url = '';
$free_status = 1;
if( $this->check_plugin_installed( $plugin ) && !$this->check_plugin_active( $plugin ) ) {
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" free version. Please activate %2$s to continue.', 'ai-addons' ),
'<strong>' . esc_html( $pro_text ) . '</strong>',
'<a href="'. esc_url( admin_url( 'plugin-install.php?tab=plugin-information&plugin=wpauto&TB_iframe=true&width=772&height=670' ) ) .'" class="thickbox open-plugin-details-modal"><strong>' . esc_html( $free_text ) . '</strong></a>'
);
$btn_txt = sprintf(
esc_html__( 'Activate %1$s', 'ai-addons' ),
esc_html( $free_text )
);
$activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin='. $plugin .'&plugin_status=all&paged=1&s', 'activate-plugin_'. $plugin );
$free_status = 0;
} elseif( !$this->check_plugin_installed( $plugin ) ) {
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" should be installed and activated. Please install %2$s to continue.', 'ai-addons' ),
'<strong>' . esc_html( $pro_text ) . '</strong>',
'<a href="'. esc_url( admin_url( 'plugin-install.php?tab=plugin-information&plugin=wpauto&TB_iframe=true&width=772&height=670' ) ) .'" class="thickbox open-plugin-details-modal"><strong>' . esc_html( $free_text ) . '</strong></a>'
);
$btn_txt = sprintf(
esc_html__( 'Install %1$s', 'ai-addons' ),
esc_html( $free_text )
);
$activation_url = wp_nonce_url( self_admin_url('update.php?action=install-plugin&plugin=wpauto'), 'install-plugin_wpauto' );
$free_status = 0;
}
if( !$free_status ) printf( '<div class="notice notice-error is-dismissible"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a></p></div>', $message, $activation_url, $btn_txt );
}
public function is_compatible(){
if ( !defined( 'WPAUTO_BILLIONAIRE' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_wpauto_free_req' ] );
return false;
}
return true;
}
public function license_manager() {
$api_url = "https://aipublish.com/";
require_once WPAUTO_DIR . "license-manager.php";
WPAuto_License_Manager::instance( WPAUTO_DIR . 'wpauto-pro.php', $api_url, "plugin", "WPAuto Pro" );
}
public function deprecated_con() {
require_once WPAUTO_DIR . "wpauto-deprecated.php";
}
public function init() {
// init wpauto functions
require_once WPAUTO_DIR . "wpauto-init.php";
// ajax functions
require_once WPAUTO_DIR . "inc/wpauto-ajax.php";
// YouTube API class
require_once WPAUTO_DIR . "inc/class.youtube-api.php";
}
public function seo_plugin() {
// seo connectivity
require_once WPAUTO_DIR . "autoseo.php";
}
public function addon_setup() {
// load text domain
$this->load_text_domain();
}
public function load_text_domain() {
load_plugin_textdomain( 'wpauto', false, WPAUTO_DIR . 'languages/' );
}
public function wpauto_activation() {
// activation redirect
add_option( 'wpauto_activation_redirect', true );
}
public function supports() {
// woo supports
if( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
require_once WPAUTO_DIR . "inc/elements/class.woo-supports.php";
}
}
public function wpauto_activation_redirect() {
// Make sure it's the correct user
if ( get_option( 'wpauto_activation_redirect', false ) ) {
// Make sure we don't redirect again after this one
delete_option( 'wpauto_activation_redirect' );
wp_safe_redirect( admin_url( 'admin.php?page=wpauto_license' ) );
exit;
}
}
public function wpauto_clear_scheduled_event() {
$timestamp = wp_next_scheduled('wpauto_pro_hook');
if ($timestamp) {
wp_unschedule_event($timestamp, 'wpauto_pro_hook');
}
$seo_timestamp = wp_next_scheduled('wpauto_pro_seo_hook');
if ($seo_timestamp) {
wp_unschedule_event($seo_timestamp, 'wpauto_pro_seo_hook');
}
}
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
} PM_WPAuto::instance();
}