'19478', 'slug' => 'ai-publisher', 'type' => 'plugin', 'public_key' => 'pk_60e8db63b31acb84ddd9c32442905', 'is_premium' => false, 'is_org_compliant' => true, 'is_premium_only' => false, 'has_addons' => false, 'has_paid_plans' => true, 'trial' => array( 'days' => 7, 'is_require_payment' => true, ), 'menu' => array( 'slug' => 'aipub_settings', ), 'is_live' => true, ) ); } return $aipub_fs; } aipub_fs(); // Signal that SDK was initiated. do_action( 'aipub_fs_loaded' ); } /* ------------------------------------------------------------------------- * Global constants * ---------------------------------------------------------------------- */ define( 'AIPUB_VERSION', '1.3.1' ); define( 'AIPUB_MIN_WP', '6.0' ); define( 'AIPUB_MIN_PHP', '7.4' ); define( 'AIPUB_FILE', __FILE__ ); define( 'AIPUB_BASENAME', plugin_basename( AIPUB_FILE ) ); define( 'AIPUB_DIR', plugin_dir_path( AIPUB_FILE ) ); define( 'AIPUB_URL', plugin_dir_url( AIPUB_FILE ) ); define( 'AIPUB_DEBUG', defined( 'WP_DEBUG' ) && WP_DEBUG ); /* ------------------------------------------------------------------------- * Environment sanity checks * ---------------------------------------------------------------------- */ if ( version_compare( PHP_VERSION, AIPUB_MIN_PHP, '<' ) ) { add_action( 'admin_notices', static function () { printf( '

%s

', esc_html( sprintf( /* translators: 1: required version, 2: current version */ __( 'TransformX Post Publisher requires PHP %1$s or higher. You are running %2$s.', 'ai-publisher' ), AIPUB_MIN_PHP, PHP_VERSION ) ) ); } ); return; } global $wp_version; if ( version_compare( $wp_version, AIPUB_MIN_WP, '<' ) ) { add_action( 'admin_notices', static function () { printf( '

%s

', esc_html( sprintf( /* translators: 1: required version, 2: current version */ __( 'TransformX Post Publisher requires WordPress %1$s or higher. You are running %2$s.', 'ai-publisher' ), AIPUB_MIN_WP, $wp_version ) ) ); } ); return; } /* ------------------------------------------------------------------------- * PSR-4 autoloader for the AiPublisher namespace * ---------------------------------------------------------------------- */ spl_autoload_register( static function ( $fqcn ) { $prefix = 'AiPublisher\\'; if ( 0 !== strpos( $fqcn, $prefix ) ) { return; // Not our namespace. } $rel_path = strtolower( str_replace( '\\', '/', substr( $fqcn, strlen( $prefix ) ) ) ); $file = AIPUB_DIR . 'includes/class-' . $rel_path . '.php'; if ( file_exists( $file ) ) { require_once $file; } } ); /* ------------------------------------------------------------------------- * Activation / deactivation hooks * ---------------------------------------------------------------------- */ /** * On activation: create uploads folder and schedule hourly cron seed. */ register_activation_hook( AIPUB_FILE, static function () { // Ensure the uploads/aipub directory exists. $upload_dir = wp_upload_dir(); $aipub_dir = trailingslashit( $upload_dir['basedir'] ) . 'aipub'; if ( !file_exists( $aipub_dir ) ) { wp_mkdir_p( $aipub_dir ); } // Seed hourly cron if not present. if ( !wp_next_scheduled( 'aipub_generate_post_event' ) ) { wp_schedule_event( time() + 60, 'hourly', 'aipub_generate_post_event' ); } } ); /** * On deactivation: clear scheduled cron hook. */ register_deactivation_hook( AIPUB_FILE, static function () { wp_clear_scheduled_hook( 'aipub_generate_post_event' ); } ); /* ------------------------------------------------------------------------- * Initialize plugin early, before plugins_loaded. * ---------------------------------------------------------------------- */ // Init Freemius. aipub_fs(); // Adjust trial promotion timing. aipub_fs()->add_filter( 'show_first_trial_after_n_sec', static fn() => 7 * 24 * 60 * 60 ); aipub_fs()->add_filter( 'reshow_trial_after_every_n_sec', static fn() => 60 * 24 * 60 * 60 ); // React to license changes such as trial start and expiration. aipub_fs()->add_action( 'after_license_change', static function ( $plan_change_desc, \FS_Plugin_Plan $plan ) { switch ( $plan_change_desc ) { case 'trial_started': // Do something immediately after a trial is started. break; case 'trial_expired': // Do something immediately after a trial expiration. break; } }, 10, 2 ); // Load translations. // Boot the plugin. ( new \AiPublisher\Loader() )->init();