| 1 |
<?php |
| 2 |
namespace ILJ\Helper; |
| 3 |
|
| 4 |
/** |
| 5 |
* Documentation toolset |
| 6 |
* |
| 7 |
* Methods for generation of help and documentation resources |
| 8 |
* |
| 9 |
* @package ILJ\Helper |
| 10 |
* @since 1.1.3 |
| 11 |
*/ |
| 12 |
class Help { |
| 13 |
|
| 14 |
/** |
| 15 |
* Document url |
| 16 |
* |
| 17 |
* @since 1.1.3 |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
public static $doc_url = 'https://www.internallinkjuicer.com/docs/%s?pm=2&utm_source=%s&utm_medium=%s&utm_campaign=%s'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Returns the plain url for manual pages |
| 24 |
* |
| 25 |
* @since 1.1.3 |
| 26 |
* @param string $docpath The path on the docs archive |
| 27 |
* @param string $anchor The anchored link within the doc page to jump to |
| 28 |
* @param string $medium The tracking medium |
| 29 |
* @param string $source The tracking source |
| 30 |
* |
| 31 |
* @return string |
| 32 |
*/ |
| 33 |
public static function getLinkUrl($docpath, $anchor, $medium, $source) { |
| 34 |
$campaign = 'plugin'; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
$url = sprintf(self::$doc_url, $docpath, urlencode($source), urlencode($medium), urlencode($campaign)); |
| 39 |
return ($anchor && '' != $anchor) ? $url . '#' . $anchor : $url; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Generates and returns the help link for manual pages |
| 44 |
* |
| 45 |
* @deprecated Deprecated, use {@link self::render_options_link} instead. |
| 46 |
* @since 1.1.3 |
| 47 |
* @param string $docpath The path on the docs archive |
| 48 |
* @param string $anchor The anchored link within the doc page to jump to |
| 49 |
* @param string $medium The tracking medium |
| 50 |
* @return string |
| 51 |
*/ |
| 52 |
public static function getOptionsLink($docpath, $anchor, $medium) { |
| 53 |
$url = self::getLinkUrl($docpath, $anchor, $medium, 'settings'); |
| 54 |
return '<a href="' . $url . '" class="help tip" rel="noopener" target="_blank" title="' . __('Get help', 'internal-links') . '"><span class="dashicons dashicons-editor-help"></span></a>'; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Renders the help link for manual pages |
| 59 |
* |
| 60 |
* @since 2.23.6 |
| 61 |
* @param string $docpath The path on the docs archive |
| 62 |
* @param string $anchor The anchored link within the doc page to jump to |
| 63 |
* @param string $medium The tracking medium |
| 64 |
* @return void |
| 65 |
*/ |
| 66 |
public static function render_options_link($docpath, $anchor, $medium) { |
| 67 |
$url = self::getLinkUrl($docpath, $anchor, $medium, 'settings'); |
| 68 |
?> |
| 69 |
<a href="<?php echo esc_url($url); ?>" class="help tip" rel="noopener" target="_blank" title="<?php esc_attr_e('Get help', 'internal-links'); ?>"> |
| 70 |
<span class="dashicons dashicons-editor-help"></span> |
| 71 |
</a> |
| 72 |
<?php |
| 73 |
} |
| 74 |
} |
| 75 |
|