| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Data Access |
| 4 |
* Plugin URI: https://wpdataaccess.com/ |
| 5 |
* Description: WP Data Access helps you to manage your local and remote data and databases from the WordPress dashboard and to publish your local and remote data on your website. |
| 6 |
* Version: 3.0.0 |
| 7 |
* Author: Peter Schulz |
| 8 |
* Author URI: https://www.linkedin.com/in/peterschulznl/ |
| 9 |
* Text Domain: wp-data-access |
| 10 |
* License: GPL-2.0+ |
| 11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 12 |
* Domain Path: /languages |
| 13 |
* |
| 14 |
* @package plugin |
| 15 |
* @author Peter Schulz |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
|
| 19 |
if ( ! defined( 'WPINC' ) ) { |
| 20 |
die; |
| 21 |
} |
| 22 |
|
| 23 |
const DONATION_URL = 'https://www.paypal.me/kpsch'; |
| 24 |
const SETTINGS_URL = 'options-general.php?page=wpdataaccess'; |
| 25 |
const REVIEW_URL = 'https://wordpress.org/support/plugin/wp-data-access/reviews/#new-post'; |
| 26 |
const STAR_IMG = '<span class="dashicons dashicons-star-filled" style="color:#ffb900;height:18px;"></span>'; |
| 27 |
const DONATION_IMG = '<img style="vertical-align:bottom;height:18px;" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif">'; |
| 28 |
|
| 29 |
//function wpda_action_links( $links ) { |
| 30 |
// // Add donation link |
| 31 |
// $donation_url = esc_url ( DONATION_URL ); |
| 32 |
// $donation_link = "<a href=\"$donation_url\">Donate</a>"; |
| 33 |
// array_unshift( $links, $donation_link ); |
| 34 |
// |
| 35 |
// // Add settings link |
| 36 |
// $settings_url = esc_url ( get_admin_url() . SETTINGS_URL ); |
| 37 |
// $settings_link = "<a href=\"$settings_url\">Settings</a>"; |
| 38 |
// array_unshift( $links, $settings_link ); |
| 39 |
// |
| 40 |
// return $links; |
| 41 |
//} |
| 42 |
//add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'wpda_action_links' ); |
| 43 |
|
| 44 |
function wpda_row_meta( $links, $file ) { |
| 45 |
if ( strpos( $file, plugin_basename(__FILE__) ) !== false ) { |
| 46 |
// Add settings link |
| 47 |
$settings_url = esc_url( get_admin_url() . SETTINGS_URL ); |
| 48 |
$settings_link = "<a href=\"$settings_url\">Settings</a>"; |
| 49 |
array_push( $links, $settings_link ); |
| 50 |
|
| 51 |
// Add review link |
| 52 |
$review_url = esc_url( REVIEW_URL ); |
| 53 |
$review_link = sprintf( "<a href=\"$review_url\">Leave a review %s%s%s%s%s</a>", STAR_IMG, STAR_IMG, STAR_IMG, STAR_IMG, STAR_IMG); |
| 54 |
array_push( $links, $review_link ); |
| 55 |
|
| 56 |
// Add donation link |
| 57 |
$donation_url = esc_url( DONATION_URL ); |
| 58 |
$donation_link = sprintf( "<a href=\"$donation_url\">Thank you for supporting me %s</a>", DONATION_IMG ); |
| 59 |
array_push( $links, $donation_link ); |
| 60 |
} |
| 61 |
|
| 62 |
return $links; |
| 63 |
} |
| 64 |
add_filter( 'plugin_row_meta', 'wpda_row_meta', 10, 2 ); |
| 65 |
|
| 66 |
// Load WPDataAccess namespace. |
| 67 |
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
| 68 |
|
| 69 |
/** |
| 70 |
* Activate plugin |
| 71 |
* |
| 72 |
* @author Peter Schulz |
| 73 |
* @since 1.0.0 |
| 74 |
*/ |
| 75 |
function activate_wp_data_access() { |
| 76 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php'; |
| 77 |
WP_Data_Access_Switch::activate(); |
| 78 |
} |
| 79 |
|
| 80 |
register_activation_hook( __FILE__, 'activate_wp_data_access' ); |
| 81 |
|
| 82 |
/** |
| 83 |
* Deactivate plugin |
| 84 |
* |
| 85 |
* @author Peter Schulz |
| 86 |
* @since 1.0.0 |
| 87 |
*/ |
| 88 |
function deactivate_wp_data_access() { |
| 89 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php'; |
| 90 |
WP_Data_Access_Switch::deactivate(); |
| 91 |
} |
| 92 |
|
| 93 |
register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' ); |
| 94 |
|
| 95 |
/** |
| 96 |
* Check if database needs to be updated |
| 97 |
* |
| 98 |
* @author Peter Schulz |
| 99 |
* @since 1.5.2 |
| 100 |
*/ |
| 101 |
function wpda_update_db_check() { |
| 102 |
if ( WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] !== get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) ) { |
| 103 |
activate_wp_data_access(); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
add_action( 'plugins_loaded', 'wpda_update_db_check' ); |
| 108 |
|
| 109 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php'; |
| 110 |
/** |
| 111 |
* Start plugin |
| 112 |
* |
| 113 |
* @author Peter Schulz |
| 114 |
* @since 1.0.0 |
| 115 |
*/ |
| 116 |
function run_wp_data_access() { |
| 117 |
$wpdataaccess = new WP_Data_Access(); |
| 118 |
$wpdataaccess->run(); |
| 119 |
} |
| 120 |
|
| 121 |
run_wp_data_access(); |
| 122 |
|