| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin User Experience controller. |
| 4 |
* |
| 5 |
* @package ContentControl\Admin |
| 6 |
* @copyright (c) 2023 Code Atlantic LLC |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ContentControl\Controllers\Admin; |
| 10 |
|
| 11 |
use ContentControl\Base\Controller; |
| 12 |
|
| 13 |
/** |
| 14 |
* UserExperience controller class. |
| 15 |
*/ |
| 16 |
class UserExperience extends Controller { |
| 17 |
|
| 18 |
/** |
| 19 |
* Initialize widget editor UX. |
| 20 |
* |
| 21 |
* @return void |
| 22 |
*/ |
| 23 |
public function init() { |
| 24 |
add_filter( 'plugin_action_links', [ $this, 'plugin_action_links' ], 10, 2 ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Render plugin action links. |
| 29 |
* |
| 30 |
* @param array<string,string> $links Existing links. |
| 31 |
* @param string $file Plugin file path. |
| 32 |
* |
| 33 |
* @return mixed |
| 34 |
*/ |
| 35 |
public function plugin_action_links( $links, $file ) { |
| 36 |
$basename = $this->container->get( 'basename' ); |
| 37 |
|
| 38 |
if ( $file === $basename ) { |
| 39 |
$plugin_action_links = apply_filters( |
| 40 |
'content_control/plugin_action_links', |
| 41 |
[ |
| 42 |
'upgrade' => '<a target="_blank" href="https://contentcontrolplugin.com/pricing/?utm_campaign=upgrade-to-pro&utm_source=plugins-page&utm_medium=plugin-ui&utm_content=action-links-upgrade-text">' . __( 'Upgrade to Pro', 'content-control' ) . '</a>', |
| 43 |
'settings' => '<a href="' . admin_url( 'options-general.php?page=content-control-settings' ) . '">' . __( 'Settings', 'content-control' ) . '</a>', |
| 44 |
] |
| 45 |
); |
| 46 |
|
| 47 |
if ( $this->container->is_pro_active() ) { |
| 48 |
unset( $plugin_action_links['upgrade'] ); |
| 49 |
} |
| 50 |
|
| 51 |
if ( substr( get_locale(), 0, 2 ) === 'en' ) { |
| 52 |
$plugin_action_links = array_merge( [ 'translate' => '<a href="' . sprintf( 'https://translate.wordpress.org/locale/%s/default/wp-plugins/content-control/', substr( get_locale(), 0, 2 ) ) . '" target="_blank">' . __( 'Translate', 'content-control' ) . '</a>' ], $plugin_action_links ); |
| 53 |
} |
| 54 |
|
| 55 |
foreach ( $plugin_action_links as $link ) { |
| 56 |
array_unshift( $links, $link ); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
return $links; |
| 61 |
} |
| 62 |
} |
| 63 |
|