set_api_url( $api_url ); $this->set_item_name( $item_name ); $this->set_slug( $slug ); $this->set_version( $version ); $this->set_item_url( $item_url ); $this->set_license_page_url( $license_page_url ); $this->set_text_domain( $text_domain ); $this->set_author( $author ); $this->set_file( $file ); $this->set_product_id( $product_id ); } /** * @param string $api_url */ public function set_api_url( $api_url ) { $this->api_url = $api_url; } /** * @return string */ public function get_api_url() { return $this->api_url; } /** * @param string $author */ public function set_author( $author ) { $this->author = $author; } /** * @return string */ public function get_author() { return $this->author; } /** * @param string $item_name */ public function set_item_name( $item_name ) { $this->item_name = $item_name; } /** * @return string */ public function get_item_name() { return $this->item_name; } /** * @param string $item_url */ public function set_item_url( $item_url ) { if ( empty( $item_url ) ) { $item_url = $this->api_url; } $this->item_url = $item_url; } /** * @return string */ public function get_item_url() { return $this->item_url; } /** * @param string $license_page_url */ public function set_license_page_url( $license_page_url ) { if ( is_admin() && is_multisite() ) { if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); } if ( is_plugin_active_for_network( $this->get_slug() ) ) { $this->license_page_url = network_admin_url( $license_page_url ); return; } } $this->license_page_url = admin_url( $license_page_url ); } /** * @return string */ public function get_license_page_url() { return $this->license_page_url; } /** * @param string $slug */ public function set_slug( $slug ) { $this->slug = $slug; } /** * @return string */ public function get_slug() { return $this->slug; } /** * Returns the dirname of the slug and limits it to 15 chars * * @return string */ public function get_transient_prefix() { return substr( md5( $this->file ), 0, 15 ); } /** * @param string $text_domain */ public function set_text_domain( $text_domain ) { $this->text_domain = $text_domain; } /** * @return string */ public function get_text_domain() { return $this->text_domain; } /** * @param string $version */ public function set_version( $version ) { $this->version = $version; } /** * @return string */ public function get_version() { return $this->version; } /** * Returns the file path relative to the plugins folder * * @return string */ public function get_file() { /* * Fall back to the slug for BC reasons. * * We used to pass the file to the slug field, but this isn't supported with the shiny updates in WordPress. * WordPress uses the slug in the HTML as an ID and a slash isn't a valid */ return empty( $this->file ) ? $this->slug : $this->file; } /** * Sets the file path relative to the plugins folder * * @param string $file Relative file path to the plugin. */ public function set_file( $file ) { $this->file = $file; } /** * Return the Product ID * * @return int */ public function get_product_id() { return $this->product_id; } /** * Set the product ID * * @param int $product_id Product ID to set. */ public function set_product_id( $product_id ) { $this->product_id = (int) $product_id; } /** * Gets a Google Analytics Campaign url for this product * * @param string $link_identifier * * @return string The full URL */ public function get_tracking_url( $link_identifier = '' ) { $tracking_vars = array( 'utm_campaign' => $this->get_item_name() . ' licensing', 'utm_medium' => 'link', 'utm_source' => $this->get_item_name(), 'utm_content' => $link_identifier ); // URL encode tracking vars. $tracking_vars = urlencode_deep( $tracking_vars ); $query_string = build_query( $tracking_vars ); return $this->get_item_url() . '#' . $query_string; } } }