| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Link Whisper Free |
| 4 |
* Version: 0.9.6 |
| 5 |
* Description: Quickly build smart internal links both to and from your content. Additionally, gain valuable insights with in-depth internal link reporting. |
| 6 |
* Author: Link Whisper |
| 7 |
* Author URI: https://linkwhisper.com |
| 8 |
* Tested up to: 7.0.2 |
| 9 |
* Text Domain: wpil |
| 10 |
*/ |
| 11 |
|
| 12 |
$dir = plugin_dir_path(__DIR__) . 'link-whisper-premium/'; |
| 13 |
if(is_dir($dir)){ |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
//autoloader |
| 18 |
spl_autoload_register( 'wpil_autoloader' ); |
| 19 |
function wpil_autoloader( $class_name ) { |
| 20 |
if ( false !== strpos( $class_name, 'Wpil' ) ) { |
| 21 |
$classes_dir = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR; |
| 22 |
$class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php'; |
| 23 |
require_once $classes_dir . $class_file; |
| 24 |
} |
| 25 |
} |
| 26 |
define( 'WPIL_STORE_URL', 'https://linkwhisper.com'); |
| 27 |
define( 'WPIL_VERSION_NUMBER', '0.9.6'); |
| 28 |
define( 'WPIL_PLUGIN_VERSION_NUMBER', '0.9.6'); |
| 29 |
define( 'WPIL_PLUGIN_OLD_VERSION_NUMBER', '0.9.5'); |
| 30 |
define( 'WP_INTERNAL_LINKING_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
| 31 |
define( 'WP_INTERNAL_LINKING_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 32 |
define( 'WPIL_PLUGIN_NAME', plugin_basename( __FILE__ )); |
| 33 |
define( 'WPIL_OPTION_IGNORE_WORDS', 'wpil_2_ignore_words'); |
| 34 |
define( 'WPIL_OPTION_IGNORE_NUMBERS', 'wpil_2_ignore_numbers'); |
| 35 |
define( 'WPIL_OPTION_UPDATE_REPORTING_DATA_ON_SAVE', 'wpil_option_update_reporting_data_on_save'); |
| 36 |
define( 'WPIL_OPTION_DONT_COUNT_INBOUND_LINKS', 'wpil_option_dont_count_inbound_links'); |
| 37 |
define( 'WPIL_OPTION_POST_TYPES', 'wpil_2_post_types'); |
| 38 |
define( 'WPIL_LINKS_OUTBOUND_INTERNAL_COUNT', 'wpil_links_outbound_internal_count'); |
| 39 |
define( 'WPIL_LINKS_INBOUND_INTERNAL_COUNT', 'wpil_links_inbound_internal_count'); |
| 40 |
define( 'WPIL_LINKS_OUTBOUND_EXTERNAL_COUNT', 'wpil_links_outbound_external_count'); |
| 41 |
define( 'WPIL_META_KEY_SYNC', 'wpil_sync_report3'); |
| 42 |
define( 'WPIL_META_KEY_SYNC_TIME', 'wpil_sync_report2_time'); |
| 43 |
define( 'WPIL_META_KEY_ADD_LINKS', 'wpil_add_links'); |
| 44 |
define( 'WPIL_EMAIL_OFFER_DISMISSED', 'wpil_email_offer_dismissed'); |
| 45 |
define( 'WPIL_SIGNED_UP_EMAIL_OFFER', 'wpil_signed_up_email_offer'); |
| 46 |
define('WPIL_OPTION_LINKS_OPEN_NEW_TAB', 'wpil_2_links_open_new_tab'); |
| 47 |
define('WPIL_OPTION_REPORT_LAST_UPDATED', 'wpil_2_report_last_updated'); |
| 48 |
define( 'WPIL_PREMIUM_NOTICE_DISMISSED', 'wpil_premium_notice_dismissed'); |
| 49 |
define( 'WPIL_LINK_TABLE_IS_CREATED', 'wpil_link_table_is_created'); |
| 50 |
define( 'WPIL_STATUS_LINK_TABLE_EXISTS', get_option(WPIL_LINK_TABLE_IS_CREATED, false)); |
| 51 |
define( 'WPIL_STATUS_PROCESSING_START', microtime(true)); |
| 52 |
define('WPIL_DEBUG_CURL', false); |
| 53 |
define('WPIL_STATUS_PLUGIN_DB_VERSION', '1.54'); // simple version counter that gets incremented when we change the existing DB tables. That way update_tables knows when and what to update. |
| 54 |
define('WPIL_STATUS_SITE_DB_VERSION', get_option('wpil_site_db_version', '0')); // existing DB version on this site |
| 55 |
define('WPIL_STATUS_HAS_RUN_SCAN', get_option('wpil_has_run_initial_scan', false)); |
| 56 |
define('WPIL_DATA_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36'); |
| 57 |
|
| 58 |
|
| 59 |
Wpil_Init::register_services(); |
| 60 |
|
| 61 |
register_activation_hook(__FILE__, [Wpil_Base::class, 'activate']); |
| 62 |
register_deactivation_hook(__FILE__, [Wpil_Base::class, 'deactivate']); |
| 63 |
register_uninstall_hook(__FILE__, array(Wpil_Base::class, 'delete_link_whisper_data')); |
| 64 |
|
| 65 |
if (is_admin()) |
| 66 |
{ |
| 67 |
if(!function_exists('get_plugin_data')) |
| 68 |
{ |
| 69 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
add_action('plugins_loaded', 'wpil_init'); |
| 75 |
|
| 76 |
if (!function_exists('wpil_init')) |
| 77 |
{ |
| 78 |
function wpil_init() |
| 79 |
{ |
| 80 |
$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
| 81 |
$locale = apply_filters('plugin_locale', $locale, 'wpil'); |
| 82 |
unload_textdomain('wpil'); |
| 83 |
load_textdomain('wpil', WP_INTERNAL_LINKING_PLUGIN_DIR . 'languages/' . "wpil-" . $locale . '.mo'); |
| 84 |
load_plugin_textdomain('wpil', false, WP_INTERNAL_LINKING_PLUGIN_DIR . 'languages'); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
add_filter('plugin_row_meta', 'wpil_filter_plugin_row_meta', 4, 10); |
| 89 |
if(!function_exists('wpil_filter_plugin_row_meta')){ |
| 90 |
function wpil_filter_plugin_row_meta($plugin_meta, $plugin_file, $plugin_data, $status){ |
| 91 |
$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] ); |
| 92 |
if($plugin_slug === 'link-whisper'){ |
| 93 |
$plugin_meta[] = sprintf( |
| 94 |
'<a href="%s" class="thickbox open-plugin-details-modal">%s</a>', |
| 95 |
esc_url( get_admin_url() . 'plugin-install.php?tab=plugin-information&plugin=link-whisper§ion=changelog&TB_iframe=true' ), |
| 96 |
__('Change Log', 'wpil') |
| 97 |
); |
| 98 |
} |
| 99 |
|
| 100 |
return $plugin_meta; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* A text logging function for use when error_log isn't a possibility. |
| 106 |
* I find myself copy-pasting file writers often enough that it makes sense to add a logger here for debugging |
| 107 |
* Can accept a string or array/object for writing |
| 108 |
* |
| 109 |
* @param mixed $content The content to write to the file. |
| 110 |
**/ |
| 111 |
if(!function_exists('WPIL_TEXT_LOGGER')){ |
| 112 |
function WPIL_TEXT_LOGGER($content){ |
| 113 |
$file = fopen(trailingslashit(WP_INTERNAL_LINKING_PLUGIN_DIR) . 'wpil_text_log.txt', 'a'); |
| 114 |
fwrite($file, print_r($content, true)); |
| 115 |
fclose($file); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
if(false){ |
| 120 |
// track errors based on shutdown in case something's not telling us there's an error |
| 121 |
function wpil_shutdown_tracking() { |
| 122 |
$error = error_get_last(); |
| 123 |
error_log(print_r(array('shutdown error tracking', 'error' => $error, 'time' => microtime(true) - WPIL_STATUS_PROCESSING_START, 'last_error' => debug_backtrace()), true)); |
| 124 |
} |
| 125 |
|
| 126 |
register_shutdown_function('wpil_shutdown_tracking'); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|