_table_columns( $columns ) { } /** * @param $manager \Groundhogg\Bulk_Jobs\Manager */ public function register_bulk_jobs( $manager ) { } /** * @param $reports Report[] * * @return array */ public function register_reports( $reports ) { return $reports; } /** * Add settings to the settings page * * @param $settings array[] * * @return array[] */ public function register_settings( $settings ) { return $settings; } /** * Add settings sections to the settings page * * @param $sections array[] * * @return array[] */ public function register_settings_sections( $sections ) { return $sections; } /** * Add settings tabs to the settings page * * @param $tabs array[] * * @return array[] */ public function register_settings_tabs( $tabs ) { return $tabs; } /** * Register any proprietary DBS * * @param $db_manager Manager */ public function register_dbs( $db_manager ) { } /** * Register any api endpoints. * * @param $api_manager * * @return void */ public function register_apis( $api_manager ) { } /** * Register any api endpoints. * * @param $api_manager API_V4_HANDLER * * @return void */ public function register_v4_apis( $api_manager ) { } /** * Register any new admin pages. * * @param $admin_menu Admin_Menu * * @return void */ public function register_admin_pages( $admin_menu ) { } /** * Get the version # * * @return mixed */ abstract public function get_version(); /** * Get the ID number for the download in EDD Store * * @return int */ abstract public function get_download_id(); protected $plugin_data = []; /** * @param string $key * * @return string */ protected function get_plugin_data( $key = 'Name' ) { if ( empty( $this->plugin_data ) ) { $this->plugin_data = get_plugin_data( $this->get_plugin_file() ); } return $this->plugin_data[ $key ]; } /** * @return string */ public function get_display_name() { return apply_filters( 'groundhogg/extension/name', $this->get_plugin_data( 'Name' ) ); } /** * @return string */ public function get_display_description() { return apply_filters( 'groundhogg/extension/description', $this->get_plugin_data( 'Description' ) ); } /** * @return string */ abstract public function get_plugin_file(); /** * Get details... * * @return array|false */ public function get_extension_details() { return get_array_var( get_option( 'gh_extensions', [] ), $this->get_download_id(), [] ); } /** * Get this extension's license key * * @return string|false */ public function get_license_key() { return get_array_var( $this->get_extension_details(), 'license' ); } /** * @return bool|string */ public function get_expiry() { if ( get_array_var( $this->get_extension_details(), 'expiry' ) === 'lifetime' ) { return false; } return date_i18n( get_option( 'date_format' ), strtotime( get_array_var( $this->get_extension_details(), 'expiry' ) ) ); } /** * Get the EDD updater. * * @return \GH_EDD_SL_Plugin_Updater */ public function get_edd_updater() { if ( ! class_exists( '\GH_EDD_SL_Plugin_Updater' ) ) { require_once __DIR__ . '/lib/edd/GH_EDD_SL_Plugin_Updater.php'; } return new \GH_EDD_SL_Plugin_Updater( License_Manager::$storeUrl, $this->get_plugin_file(), [ 'version' => $this->get_version(), 'license' => $this->get_license_key(), 'item_id' => $this->get_download_id(), 'author' => $this->get_author(), 'url' => home_url(), 'beta' => is_option_enabled( 'gh_get_beta_versions' ), ] ); } /** * Return the author string * * @return string */ protected function get_author() { if ( ! is_white_labeled() ) { return 'Groundhogg Inc.'; } else { return white_labeled_name(); } } final public function __clone() { trigger_error( "Singleton. No cloning allowed!", E_USER_ERROR ); } final public function __wakeup() { trigger_error( "Singleton. No serialization allowed!", E_USER_ERROR ); } /** * Whether the license is valid * * @return bool */ public function license_is_valid() { $status = get_array_var( $this->get_extension_details(), 'status' ); return $status === 'valid'; } /** * Return the license status string */ public function license_status() { $status = get_array_var( $this->get_extension_details(), 'status' ); $status = html()->e( 'span', [ 'class' => 'status-' . $status ], $status === 'valid' ? __( 'valid', 'groundhogg' ) : __( 'invalid', 'groundhogg' ) ); $expires = $this->get_expiry() ? sprintf( __( 'expires on %1$s', 'groundhogg' ), $this->get_expiry() ) : __( 'never expires', 'groundhogg' ); return sprintf( __( "Your license is %s and %s.", 'groundhogg' ), $status, $expires ); } /** * @return string */ public function __toString() { $content = "
"; $content .= "
"; $content .= "

{$this->get_display_name()}

"; $content .= "
"; $content .= "
"; $content .= "

" . $this->get_display_description() . "

"; $content .= html()->input( [ 'placeholder' => __( 'License', 'groundhogg' ), 'name' => "license[{$this->get_download_id()}]", 'value' => $this->get_license_key(), 'type' => $this->get_license_key() ? 'password' : 'text' ] ); if ( $this->get_license_key() ) { $content .= "

"; $content .= $this->license_status(); $content .= "

"; $content .= html()->wrap( [ html()->wrap( __( 'Check', 'groundhogg' ), 'a', [ 'class' => 'gh-button secondary', 'href' => admin_url( wp_nonce_url( add_query_arg( [ 'action' => 'check_license', 'extension' => $this->get_download_id() ], 'admin.php?page=gh_settings&tab=extensions' ) ) ) ] ), html()->wrap( __( 'Deactivate', 'groundhogg' ), 'a', [ 'class' => 'gh-button danger text', 'href' => admin_url( wp_nonce_url( add_query_arg( [ 'action' => 'deactivate_license', 'extension' => $this->get_download_id() ], 'admin.php?page=gh_settings&tab=extensions' ) ) ) ] ), ], 'div', [ 'class' => 'display-flex gap-10' ] ); } else { $content .= html()->wrap( html()->input( [ 'type' => 'submit', 'name' => 'activate_license', 'class' => 'gh-button primary', 'value' => __( 'Activate', 'groundhogg' ), ] ), 'p' ); } $content .= "
"; $content .= "
"; return $content; } }