admin
2 months ago
register-hooks
3 years ago
class-wpel-front-ignore.php
3 years ago
class-wpel-front.php
4 months ago
class-wpel-link.php
3 years ago
class-wpel-plugin.php
1 year ago
class-wpel-register-scripts.php
2 months ago
class-wpel-template-tags.php
3 years ago
class-wpel-update.php
3 years ago
index.php
6 years ago
class-wpel-link.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WPEL_Link |
| 4 | * |
| 5 | * This class extends DOMElement which uses the camelCase naming style. |
| 6 | * Therefore this class also contains camelCase names. |
| 7 | * |
| 8 | * @package WPEL |
| 9 | * @category WordPress Plugin |
| 10 | * @version 2.3 |
| 11 | * @link https://www.webfactoryltd.com/ |
| 12 | * @license Dual licensed under the MIT and GPLv2+ licenses |
| 13 | */ |
| 14 | class WPEL_Link extends FWP_HTML_Element_1x0x0 |
| 15 | { |
| 16 | |
| 17 | /** |
| 18 | * Mark as external link (by setting data attribute) |
| 19 | */ |
| 20 | public function set_external() |
| 21 | { |
| 22 | $this->set_attr( 'data-wpel-link', 'external' ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Is marked as external link |
| 27 | * @return boolean |
| 28 | */ |
| 29 | public function is_external() |
| 30 | { |
| 31 | return 'external' === $this->get_attr( 'data-wpel-link' ) || $this->has_attr_value( 'rel', 'external' ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Mark as internal link (by setting data attribute) |
| 36 | */ |
| 37 | public function set_internal() |
| 38 | { |
| 39 | $this->set_attr( 'data-wpel-link', 'internal' ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Is marked as internal link |
| 44 | * @return boolean |
| 45 | */ |
| 46 | public function is_internal() |
| 47 | { |
| 48 | return 'internal' === $this->get_attr( 'data-wpel-link' ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Mark as excluded link (by setting data attribute) |
| 53 | */ |
| 54 | public function set_exclude() |
| 55 | { |
| 56 | $this->set_attr( 'data-wpel-link', 'exclude' ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Is marked as excluded link |
| 61 | * @return boolean |
| 62 | */ |
| 63 | public function is_exclude() |
| 64 | { |
| 65 | return 'exclude' === $this->get_attr( 'data-wpel-link' ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Mark as ignored link (by setting data attribute) |
| 70 | */ |
| 71 | public function set_ignore() |
| 72 | { |
| 73 | $this->set_attr( 'data-wpel-link', 'ignore' ); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Is marked as ignored link |
| 78 | * @return boolean |
| 79 | */ |
| 80 | public function is_ignore() |
| 81 | { |
| 82 | return 'ignore' === $this->get_attr( 'data-wpel-link' ); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Check url is mailto link |
| 87 | * @return boolean |
| 88 | */ |
| 89 | public function is_mailto() |
| 90 | { |
| 91 | $url = trim( $this->get_attr( 'href' ) ); |
| 92 | |
| 93 | if ( substr( $url, 0, 7 ) === 'mailto:' ) { |
| 94 | return true; |
| 95 | } |
| 96 | |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | } |
| 101 |