| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package ALM |
| 5 |
* @author WPSAAD |
| 6 |
* @link https://wpsaad.com |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
/** |
| 10 |
* Plugin Name: Image Alt Text Manager |
| 11 |
* plugin URI: https://wpsaad.com/alt-manager-wordpress-image-alt-text-plugin/ |
| 12 |
* Description:Automatically bulk change images alt text to dynamic alt tags values related to content or media and also generate empty values for both alt and title tags. |
| 13 |
* Version: 1.9.4 |
| 14 |
* Author: WPSAAD |
| 15 |
* Author URI: https://wpsaad.com |
| 16 |
* License: GPLv2 or later |
| 17 |
* Text Domain: alt-manager |
| 18 |
* Domain Path: /languages |
| 19 |
*/ |
| 20 |
defined( 'ABSPATH' ) or die; |
| 21 |
if ( function_exists( 'am_fs' ) ) { |
| 22 |
am_fs()->set_basename( false, __FILE__ ); |
| 23 |
} else { |
| 24 |
if ( !function_exists( 'am_fs' ) ) { |
| 25 |
// Create a helper function for easy SDK access. |
| 26 |
function am_fs() { |
| 27 |
global $am_fs; |
| 28 |
if ( !isset( $am_fs ) ) { |
| 29 |
// Include Freemius SDK. |
| 30 |
require_once dirname( __FILE__ ) . '/freemius/start.php'; |
| 31 |
$am_fs = fs_dynamic_init( array( |
| 32 |
'id' => '5548', |
| 33 |
'slug' => 'alt-manager', |
| 34 |
'type' => 'plugin', |
| 35 |
'navigation' => 'tabs', |
| 36 |
'public_key' => 'pk_07c4f76da780308f88546ce3da78a', |
| 37 |
'is_premium' => false, |
| 38 |
'premium_suffix' => 'premium plan', |
| 39 |
'has_addons' => false, |
| 40 |
'has_paid_plans' => true, |
| 41 |
'menu' => array( |
| 42 |
'slug' => 'alt-manager', |
| 43 |
'parent' => array( |
| 44 |
'slug' => 'options-general.php', |
| 45 |
), |
| 46 |
), |
| 47 |
'is_live' => true, |
| 48 |
'is_org_compliant' => true, |
| 49 |
) ); |
| 50 |
} |
| 51 |
return $am_fs; |
| 52 |
} |
| 53 |
|
| 54 |
// Init Freemius. |
| 55 |
am_fs(); |
| 56 |
// Signal that SDK was initiated. |
| 57 |
do_action( 'am_fs_loaded' ); |
| 58 |
} |
| 59 |
//check if we are on plugin page to load styles only there |
| 60 |
global $plugin_page; |
| 61 |
$current_page = ( isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '' ); |
| 62 |
if ( $plugin_page === 'alt-manager' || $current_page === 'alt-manager' ) { |
| 63 |
//add style |
| 64 |
add_action( 'admin_enqueue_scripts', 'alm_style' ); |
| 65 |
} |
| 66 |
/** |
| 67 |
* Enqueue admin scripts and styles |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
function alm_style() { |
| 72 |
wp_enqueue_script( 'switcher-script', plugins_url( '/assets/js/jquery.switcher.min.js', __FILE__ ) ); |
| 73 |
wp_enqueue_style( 'switcher-style', plugins_url( '/assets/css/switcher.css', __FILE__ ) ); |
| 74 |
wp_enqueue_script( 'select2-script', plugins_url( '/assets/js/select2.min.js', __FILE__ ) ); |
| 75 |
wp_enqueue_style( 'select2-style', plugins_url( '/assets/css/select2.min.css', __FILE__ ) ); |
| 76 |
wp_enqueue_script( 'alm-admin-script', plugins_url( '/assets/js/alm-admin.js', __FILE__ ) ); |
| 77 |
wp_enqueue_style( 'alm-admin-style', plugins_url( '/assets/css/alm-admin-styles.css', __FILE__ ) ); |
| 78 |
if ( function_exists( 'am_fs' ) && am_fs()->is__premium_only() ) { |
| 79 |
//ai api check and ajax |
| 80 |
wp_enqueue_script( |
| 81 |
'alm-progress', |
| 82 |
plugins_url( '/assets/js/alm-progress.js', __FILE__ ), |
| 83 |
['jquery'], |
| 84 |
'1.0', |
| 85 |
true |
| 86 |
); |
| 87 |
// Use a plugin-specific object so we do not overwrite WordPress's global ajaxurl string. |
| 88 |
wp_localize_script( 'alm-progress', 'almProgress', array( |
| 89 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 90 |
) ); |
| 91 |
} |
| 92 |
if ( is_rtl() ) { |
| 93 |
wp_enqueue_style( 'alm-admin-style-rtl', plugins_url( '/assets/css/alm-admin-styles-rtl.css', __FILE__ ) ); |
| 94 |
} |
| 95 |
// wp_enqueue_script('jquery-ui-sortable'); |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Get option value (multisite compatible) |
| 100 |
* |
| 101 |
* @param string $option Option name. |
| 102 |
* @param mixed $default Default value. |
| 103 |
* @return mixed Option value. |
| 104 |
*/ |
| 105 |
function alm_get_option( $option, $default = false ) { |
| 106 |
if ( is_multisite() && is_network_admin() ) { |
| 107 |
return get_site_option( $option, $default ); |
| 108 |
} |
| 109 |
return get_option( $option, $default ); |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Update option value (multisite compatible) |
| 114 |
* |
| 115 |
* @param string $option Option name. |
| 116 |
* @param mixed $value Option value. |
| 117 |
* @return bool True on success, false on failure. |
| 118 |
*/ |
| 119 |
function alm_update_option( $option, $value ) { |
| 120 |
if ( is_multisite() && is_network_admin() ) { |
| 121 |
return update_site_option( $option, $value ); |
| 122 |
} |
| 123 |
return update_option( $option, $value ); |
| 124 |
} |
| 125 |
|
| 126 |
//load plugin required files |
| 127 |
add_action( 'init', 'alm_load' ); |
| 128 |
/** |
| 129 |
* Load plugin required files |
| 130 |
* |
| 131 |
* @return void |
| 132 |
*/ |
| 133 |
function alm_load() { |
| 134 |
require_once plugin_dir_path( __FILE__ ) . 'inc/alm-functions.php'; |
| 135 |
require_once plugin_dir_path( __FILE__ ) . 'inc/alm-empty-generator.php'; |
| 136 |
if ( user_can( get_current_user_id(), 'manage_options' ) ) { |
| 137 |
include_once plugin_dir_path( __FILE__ ) . 'inc/alm-admin.php'; |
| 138 |
} |
| 139 |
if ( !function_exists( 'file_get_html' ) ) { |
| 140 |
require_once plugin_dir_path( __FILE__ ) . 'inc/simple_html_dom.php'; |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
//Activation & Reset |
| 145 |
//Generate activaition class |
| 146 |
if ( !class_exists( 'almActivate' ) ) { |
| 147 |
require_once plugin_dir_path( __FILE__ ) . 'inc/alm-activate.php'; |
| 148 |
} |
| 149 |
//Activation Hook |
| 150 |
register_activation_hook( __FILE__, array('almActivate', 'activate') ); |
| 151 |
add_action( 'admin_init', 'admin_page_functions' ); |
| 152 |
/** |
| 153 |
* Handle admin page functions and actions |
| 154 |
* |
| 155 |
* @return void |
| 156 |
*/ |
| 157 |
function admin_page_functions() { |
| 158 |
//Reset Action |
| 159 |
if ( user_can( get_current_user_id(), 'manage_options' ) && isset( $_REQUEST['reset'] ) && isset( $_POST['reset_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['reset_nonce'] ) ), 'alm_reset_nonce' ) ) { |
| 160 |
$activate_reset = new almActivate(); |
| 161 |
$activate_reset->reset(); |
| 162 |
} |
| 163 |
if ( user_can( get_current_user_id(), 'manage_options' ) ) { |
| 164 |
include_once plugin_dir_path( __FILE__ ) . 'inc/alm-settings.php'; |
| 165 |
if ( function_exists( 'am_fs' ) && am_fs()->is__premium_only() ) { |
| 166 |
//AI Generator Action |
| 167 |
include_once plugin_dir_path( __FILE__ ) . 'inc/ai-generator__premium_only.php'; |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
} |