Admin
3 years ago
Ajax
3 years ago
ApplyFilter
3 years ago
Asset
3 years ago
Capabilities
3 years ago
Check
2 years ago
Column
3 years ago
ColumnRepository
3 years ago
ColumnSize
3 years ago
Controller
3 years ago
Deprecated
3 years ago
Exception
3 years ago
Form
3 years ago
Helper
3 years ago
Integration
3 years ago
ListScreen
3 years ago
ListScreenRepository
3 years ago
ListTable
3 years ago
Message
3 years ago
Meta
3 years ago
Nonce
3 years ago
Plugin
3 years ago
Preferences
3 years ago
Promo
3 years ago
Relation
3 years ago
Request
3 years ago
Response
3 years ago
Sanitize
3 years ago
Screen
3 years ago
Service
3 years ago
Settings
3 years ago
Storage
3 years ago
Table
3 years ago
ThirdParty
3 years ago
Transient
3 years ago
Type
3 years ago
AdminColumns.php
3 years ago
ApplyFilter.php
3 years ago
ArrayIterator.php
3 years ago
Capabilities.php
3 years ago
Collection.php
3 years ago
Column.php
3 years ago
ColumnGroups.php
3 years ago
ColumnRepository.php
3 years ago
Config.php
3 years ago
DefaultColumnsRepository.php
3 years ago
Dependencies.php
3 years ago
EncodedListScreenData.php
3 years ago
EncodedListScreenDataFactory.php
3 years ago
Expirable.php
3 years ago
Groups.php
3 years ago
Helper.php
3 years ago
Integration.php
3 years ago
IntegrationRepository.php
3 years ago
Integrations.php
3 years ago
Iterator.php
3 years ago
ListScreen.php
3 years ago
ListScreenCollection.php
3 years ago
ListScreenFactory.php
3 years ago
ListScreenGroups.php
3 years ago
ListScreenPost.php
3 years ago
ListScreenRepository.php
3 years ago
ListScreenRepositoryWritable.php
3 years ago
ListScreenTypes.php
3 years ago
ListScreenWP.php
3 years ago
ListScreens.php
3 years ago
ListTable.php
3 years ago
ListTableFactory.php
3 years ago
Message.php
3 years ago
MetaType.php
3 years ago
Middleware.php
3 years ago
OpCacheInvalidateTrait.php
3 years ago
Plugin.php
3 years ago
PluginActionLinks.php
3 years ago
PluginInformation.php
3 years ago
PluginUpdate.php
3 years ago
Preferences.php
3 years ago
Promo.php
3 years ago
PromoCollection.php
3 years ago
Registerable.php
3 years ago
Relation.php
3 years ago
Renderable.php
3 years ago
Request.php
3 years ago
Sanitize.php
3 years ago
Screen.php
3 years ago
ScreenController.php
3 years ago
Stringable.php
3 years ago
Transient.php
3 years ago
TypedArrayIterator.php
3 years ago
View.php
3 years ago
ViewCollection.php
3 years ago
WpListTableFactory.php
3 years ago
Integration.php
142 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC; |
| 4 | |
| 5 | use AC\Type\Url; |
| 6 | |
| 7 | abstract class Integration { |
| 8 | |
| 9 | /** @var string */ |
| 10 | private $basename; |
| 11 | |
| 12 | /** @var string */ |
| 13 | private $title; |
| 14 | |
| 15 | /** @var string */ |
| 16 | private $logo; |
| 17 | |
| 18 | /** @var Url */ |
| 19 | private $url; |
| 20 | |
| 21 | /** @var string */ |
| 22 | private $plugin_link; |
| 23 | |
| 24 | /** |
| 25 | * @var string |
| 26 | */ |
| 27 | private $description; |
| 28 | |
| 29 | /** |
| 30 | * @param string $basename |
| 31 | * @param string $title |
| 32 | * @param string $logo |
| 33 | * @param string $description |
| 34 | * @param string $plugin_link |
| 35 | * @param Url $url |
| 36 | */ |
| 37 | public function __construct( $basename, $title, $logo, $description, $plugin_link = null, Url $url = null ) { |
| 38 | if ( null === $plugin_link ) { |
| 39 | $plugin_link = $this->search_plugin( $title ); |
| 40 | } |
| 41 | |
| 42 | if ( null === $url ) { |
| 43 | $url = new Url\Site( Url\Site::PAGE_PRICING ); |
| 44 | } |
| 45 | |
| 46 | $this->basename = $basename; |
| 47 | $this->title = $title; |
| 48 | $this->logo = $logo; |
| 49 | $this->description = $description; |
| 50 | $this->plugin_link = $plugin_link; |
| 51 | $this->url = $url; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @return bool |
| 56 | */ |
| 57 | abstract public function is_plugin_active(); |
| 58 | |
| 59 | /** |
| 60 | * @param Screen $screen |
| 61 | * |
| 62 | * @return bool |
| 63 | */ |
| 64 | abstract public function show_notice( Screen $screen ); |
| 65 | |
| 66 | /** |
| 67 | * @param string $name |
| 68 | * |
| 69 | * @return string |
| 70 | */ |
| 71 | private function search_plugin( $name ) { |
| 72 | return add_query_arg( |
| 73 | [ |
| 74 | 'tab' => 'search', |
| 75 | 'type' => 'term', |
| 76 | 's' => $name, |
| 77 | ], |
| 78 | admin_url( 'plugin-install.php' ) |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @return string |
| 84 | */ |
| 85 | public function get_basename() { |
| 86 | return $this->basename; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @return string |
| 91 | */ |
| 92 | public function get_slug() { |
| 93 | return dirname( $this->basename ); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @return string |
| 98 | */ |
| 99 | public function get_title() { |
| 100 | return $this->title; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @return string |
| 105 | */ |
| 106 | public function get_logo() { |
| 107 | return $this->logo; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @return string |
| 112 | */ |
| 113 | public function get_description() { |
| 114 | return $this->description; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @return string |
| 119 | */ |
| 120 | public function get_link() { |
| 121 | return ( new Url\UtmTags( $this->url, 'addon', $this->get_slug() ) )->get_url(); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @return string |
| 126 | */ |
| 127 | public function get_plugin_link() { |
| 128 | return $this->plugin_link; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Determines when the placeholder column is shown for a particular list screen. |
| 133 | * |
| 134 | * @param ListScreen $list_screen |
| 135 | * |
| 136 | * @return bool |
| 137 | */ |
| 138 | public function show_placeholder( ListScreen $list_screen ) { |
| 139 | return true; |
| 140 | } |
| 141 | |
| 142 | } |