← All changes
|
includes/admin/notices/class-wdkit-plugin-page.php
+73
-19
1.0.13
→
2.7.0
View file →
| @@ -33,8 +33,18 @@ | ||
| 33 | 33 | */ |
| 34 | 34 | private static $instance; |
| 35 | 35 | |
| 36 | 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 | + /** | |
| 37 | 47 | * Singleton instance getter method. |
| 38 | 48 | * |
| 39 | 49 | * @since 1.0.0 |
| 40 | 50 | * |
| @@ -55,19 +65,19 @@ | ||
| 55 | 65 | * and has the capability to manage options. If these conditions are met, it adds specific |
| 56 | 66 | * filters to enhance the plugin's functionality in the admin area. |
| 57 | 67 | * |
| 58 | 68 | * @since 1.0.0 |
| 59 | - * @access public | |
| 60 | 69 | */ |
| 61 | 70 | public function __construct() { |
| 71 | + $this->white_label = get_option( 'wkit_white_label' ); | |
| 62 | 72 | |
| 63 | - if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
| 64 | - // Add a filter to include a settings link for the plugin in the WordPress plugins page. | |
| 65 | - add_filter( 'plugin_action_links_' . WDKIT_PBNAME, array( $this, 'wdkit_settings_pro_link' ) ); | |
| 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' ) ); | |
| 66 | 75 | |
| 67 | - // Add a filter to include additional links/meta for the plugin on the WordPress plugins page. | |
| 68 | - add_filter( 'plugin_row_meta', array( $this, 'wdkit_extra_links_plugin_row_meta' ), 10, 2 ); | |
| 69 | - } | |
| 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 ); | |
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | /** |
| 73 | 83 | * Generates additional links for the plugin on the plugins page. |
| @@ -75,9 +85,8 @@ | ||
| 75 | 85 | * This function modifies the plugin's action links by adding custom links for 'Settings' and 'Need Help?' |
| 76 | 86 | * to the existing list of links displayed on the WordPress plugins page. |
| 77 | 87 | * |
| 78 | 88 | * @since 1.0.0 |
| 79 | - * @access public | |
| 80 | 89 | * |
| 81 | 90 | * @param string[] $links An array containing the existing links for the plugin. |
| 82 | 91 | * @return string[] An updated array with additional custom links. |
| 83 | 92 | */ |
| @@ -82,23 +91,53 @@ | ||
| 82 | 91 | * @return string[] An updated array with additional custom links. |
| 83 | 92 | */ |
| 84 | 93 | public function wdkit_settings_pro_link( $links ) { |
| 85 | 94 | |
| 86 | - $settings = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=wdesign-kit#/login' ), __( 'Settings', 'wdesignkit' ) ); | |
| 87 | - $need_help = sprintf( '<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', esc_url( 'https://wdesignkit.com/' ), __( 'Need Help?', 'wdesignkit' ) ); | |
| 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' ) ); | |
| 88 | 98 | |
| 89 | - $links = (array) $links; | |
| 99 | + $links = (array) $links; | |
| 100 | + | |
| 101 | + if ( empty( $this->white_label['help_link'] ) ) { | |
| 102 | + $links[] = $upgrade_pro; | |
| 103 | + } | |
| 104 | + | |
| 90 | 105 | $links[] = $settings; |
| 91 | - $links[] = $need_help; | |
| 92 | 106 | |
| 107 | + if ( empty( $this->white_label['help_link'] ) ) { | |
| 108 | + $links[] = $need_help; | |
| 109 | + } | |
| 110 | + | |
| 93 | 111 | return $links; |
| 94 | 112 | } |
| 95 | 113 | |
| 96 | 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 | + /** | |
| 97 | 137 | * Adds extra links/meta to the plugin's row on the WordPress plugins page. |
| 98 | 138 | * |
| 99 | 139 | * @since 1.0.0 |
| 100 | - * @access public | |
| 101 | 140 | * |
| 102 | 141 | * @param string $plugin_meta return full array. |
| 103 | 142 | * @param string $plugin_file check path. |
| 104 | 143 | * @return array An updated array containing additional custom links/meta. |
| @@ -105,15 +144,30 @@ | ||
| 105 | 144 | */ |
| 106 | 145 | public function wdkit_extra_links_plugin_row_meta( $plugin_meta = array(), $plugin_file = '' ) { |
| 107 | 146 | |
| 108 | 147 | if ( strpos( $plugin_file, WDKIT_PBNAME ) !== false ) { |
| 109 | - $new_links = array( | |
| 110 | - 'join-community' => '<a href="' . esc_url( 'https://www.facebook.com/groups/wdesignkit' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Join Community', 'wdesignkit' ) . '</a>', | |
| 111 | - 'whats-new' => '<a href="' . esc_url( 'https://roadmap.wdesignkit.com/roadmap' ) . '" target="_blank" rel="noopener noreferrer" style="color: orange;">' . esc_html__( 'What\'s New?', 'wdesignkit' ) . '</a>', | |
| 112 | - 'req-feature' => '<a href="' . esc_url( 'https://roadmap.wdesignkit.com/boards/feature-requests' ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Request Feature', 'wdesignkit' ) . '</a>', | |
| 113 | - ); | |
| 114 | 148 | |
| 115 | - $plugin_meta = array_merge( $plugin_meta, $new_links ); | |
| 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 | + } | |
| 116 | 170 | } |
| 117 | 171 | |
| 118 | 172 | return $plugin_meta; |
| 119 | 173 | } |