| 1 |
<?php |
| 2 |
/** |
| 3 |
* The file that defines the core plugin class |
| 4 |
* |
| 5 |
* A class definition that includes attributes and functions used across both the |
| 6 |
* public-facing side of the site and the admin area. |
| 7 |
* |
| 8 |
* @link https://posimyth.com/ |
| 9 |
* @since 1.0.0 |
| 10 |
* |
| 11 |
* @package Wdesignkit |
| 12 |
* @subpackage Wdesignkit/includes |
| 13 |
*/ |
| 14 |
|
| 15 |
/**Exit if accessed directly.*/ |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
if ( ! class_exists( 'Wdkit_Plugin_Page' ) ) { |
| 21 |
|
| 22 |
/** |
| 23 |
* Wdkit_Plugin_Page |
| 24 |
* |
| 25 |
* @since 1.0.0 |
| 26 |
*/ |
| 27 |
class Wdkit_Plugin_Page { |
| 28 |
|
| 29 |
/** |
| 30 |
* Singleton instance variable. |
| 31 |
* |
| 32 |
* @var instance|null The single instance of the class. |
| 33 |
*/ |
| 34 |
private static $instance; |
| 35 |
|
| 36 |
/** |
| 37 |
* Indicates whether the white label mode is enabled. |
| 38 |
* |
| 39 |
* When set to true, the application will operate in white label mode, |
| 40 |
* hiding branding and other related elements. |
| 41 |
* |
| 42 |
* @var bool |
| 43 |
*/ |
| 44 |
public $white_label; |
| 45 |
|
| 46 |
/** |
| 47 |
* Singleton instance getter method. |
| 48 |
* |
| 49 |
* @since 1.0.0 |
| 50 |
* |
| 51 |
* @return self The single instance of the class. |
| 52 |
*/ |
| 53 |
public static function get_instance() { |
| 54 |
if ( ! isset( self::$instance ) ) { |
| 55 |
self::$instance = new self(); |
| 56 |
} |
| 57 |
|
| 58 |
return self::$instance; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Initializes the core functionalities of the plugin for admin users with 'manage_options' capability. |
| 63 |
* |
| 64 |
* This constructor method checks if the current user is in the WordPress admin dashboard |
| 65 |
* and has the capability to manage options. If these conditions are met, it adds specific |
| 66 |
* filters to enhance the plugin's functionality in the admin area. |
| 67 |
* |
| 68 |
* @since 1.0.0 |
| 69 |
*/ |
| 70 |
public function __construct() { |
| 71 |
$this->white_label = get_option( 'wkit_white_label' ); |
| 72 |
|
| 73 |
// Add a filter to include a settings link for the plugin in the WordPress plugins page. |
| 74 |
add_filter( 'plugin_action_links_' . WDKIT_PBNAME, array( $this, 'wdkit_settings_pro_link' ) ); |
| 75 |
|
| 76 |
// Add a filter to include additional links/meta for the plugin on the WordPress plugins page. |
| 77 |
add_filter( 'plugin_row_meta', array( $this, 'wdkit_extra_links_plugin_row_meta' ), 10, 2 ); |
| 78 |
|
| 79 |
add_filter( 'all_plugins', array( $this, 'wdkit_plugin_row_meta' ), 10, 2 ); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Generates additional links for the plugin on the plugins page. |
| 84 |
* |
| 85 |
* This function modifies the plugin's action links by adding custom links for 'Settings' and 'Need Help?' |
| 86 |
* to the existing list of links displayed on the WordPress plugins page. |
| 87 |
* |
| 88 |
* @since 1.0.0 |
| 89 |
* |
| 90 |
* @param string[] $links An array containing the existing links for the plugin. |
| 91 |
* @return string[] An updated array with additional custom links. |
| 92 |
*/ |
| 93 |
public function wdkit_settings_pro_link( $links ) { |
| 94 |
|
| 95 |
$settings = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=wdesign-kit#/settings' ), __( 'Settings', 'wdesignkit' ) ); |
| 96 |
$upgrade_pro = sprintf( '<a href="%s" target="_blank" rel="noopener noreferrer" style="font-weight: bold;">%s</a>', esc_url( 'https://wdesignkit.com/pricing?utm_source=wpbackend&utm_medium=pluginpage&utm_campaign=admin' ), __( 'Upgrade PRO', 'wdesignkit' ) ); |
| 97 |
$need_help = sprintf( '<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', esc_url( 'https://store.posimyth.com/get-support-wdesignkit' ), __( 'Need Help?', 'wdesignkit' ) ); |
| 98 |
|
| 99 |
$links = (array) $links; |
| 100 |
|
| 101 |
if ( empty( $this->white_label['help_link'] ) ) { |
| 102 |
$links[] = $upgrade_pro; |
| 103 |
} |
| 104 |
|
| 105 |
$links[] = $settings; |
| 106 |
|
| 107 |
if ( empty( $this->white_label['help_link'] ) ) { |
| 108 |
$links[] = $need_help; |
| 109 |
} |
| 110 |
|
| 111 |
return $links; |
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* Modify plugin row metadata. |
| 116 |
* |
| 117 |
* @since 1.1.9 |
| 118 |
* @param array $plugins Array of all installed plugins. |
| 119 |
* @return array Modified array of plugins. |
| 120 |
*/ |
| 121 |
public function wdkit_plugin_row_meta( $plugins ) { |
| 122 |
|
| 123 |
foreach ( $plugins as $plugin_file => $plugin_data ) { |
| 124 |
if ( WDKIT_PBNAME === $plugin_file && !empty($this->white_label) ) { |
| 125 |
$plugins[ $plugin_file ]['Title'] = ! empty( $this->white_label['plugin_name'] ) ? $this->white_label['plugin_name'] : ''; |
| 126 |
$plugins[ $plugin_file ]['Author'] = ! empty( $this->white_label['developer_name'] ) ? $this->white_label['developer_name'] : ''; |
| 127 |
$plugins[ $plugin_file ]['AuthorName'] = ! empty( $this->white_label['developer_name'] ) ? $this->white_label['developer_name'] : ''; |
| 128 |
$plugins[ $plugin_file ]['AuthorURI'] = ! empty( $this->white_label['website_url'] ) ? $this->white_label['website_url'] : ''; |
| 129 |
$plugins[ $plugin_file ]['Description'] = ! empty( $this->white_label['plugin_desc'] ) ? $this->white_label['plugin_desc'] : ''; |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
return $plugins; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Adds extra links/meta to the plugin's row on the WordPress plugins page. |
| 138 |
* |
| 139 |
* @since 1.0.0 |
| 140 |
* |
| 141 |
* @param string $plugin_meta return full array. |
| 142 |
* @param string $plugin_file check path. |
| 143 |
* @return array An updated array containing additional custom links/meta. |
| 144 |
*/ |
| 145 |
public function wdkit_extra_links_plugin_row_meta( $plugin_meta = array(), $plugin_file = '' ) { |
| 146 |
|
| 147 |
if ( strpos( $plugin_file, WDKIT_PBNAME ) !== false ) { |
| 148 |
|
| 149 |
if ( empty( $this->white_label['help_link'] ) ) { |
| 150 |
$new_links = array( |
| 151 |
'official-Website' => '<a href="' . esc_url( 'https://wdesignkit.com/?utm_source=wpbackend&utm_medium=pluginpage&utm_campaign=admin' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Official Website', 'wdesignkit' ) . '</a>', |
| 152 |
'docs' => '<a href="' . esc_url( 'https://learn.wdesignkit.com/?utm_source=wpbackend&utm_medium=pluginpage&utm_campaign=admin' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'docs', 'wdesignkit' ) . '</a>', |
| 153 |
'video-tutorials' => '<a href="' . esc_url( 'https://www.youtube.com/c/POSIMYTHInnovations/?sub_confirmation=1' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Video Tutorials', 'wdesignkit' ) . '</a>', |
| 154 |
'join-community' => '<a href="' . esc_url( 'https://www.facebook.com/groups/wdesignkit' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Join Community', 'wdesignkit' ) . '</a>', |
| 155 |
'whats-new?' => '<a href="' . esc_url( 'https://roadmap.wdesignkit.com/updates' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( "What's New?", 'wdesignkit' ) . '</a>', |
| 156 |
'request-feature' => '<a href="' . esc_url( 'https://roadmap.wdesignkit.com/boards/feature-requests' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Request Feature', 'wdesignkit' ) . '</a>', |
| 157 |
'rate-stars' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/wdesignkit/reviews/?filter=5' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Rate 5 Stars', 'wdesignkit' ) . '</a>', |
| 158 |
); |
| 159 |
|
| 160 |
$plugin_meta = array_merge( $plugin_meta, $new_links ); |
| 161 |
} |
| 162 |
|
| 163 |
if ( ! empty( $this->white_label['help_link'] ) ) { |
| 164 |
foreach ( $plugin_meta as $key => $meta ) { |
| 165 |
if ( stripos( $meta, 'View details' ) !== false ) { |
| 166 |
unset( $plugin_meta[ $key ] ); |
| 167 |
} |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
return $plugin_meta; |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
Wdkit_Plugin_Page::get_instance(); |
| 177 |
} |
| 178 |
|