| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @author Podlove <[email protected]> |
||
| 4 | * @copyright Copyright (c) 2014-2018, Podlove |
||
| 5 | * @license https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT |
||
| 6 | * @package Podlove\PodloveSubscribeButton |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace PodloveSubscribeButton; |
||
| 10 | |||
| 11 | Class Helpers { |
||
| 12 | |||
| 13 | public static function get_path( $folder = '' ) { |
||
| 14 | |||
| 15 | $path = untrailingslashit( plugin_dir_path( \PodloveSubscribeButton::plugin_file() ) ); |
||
| 16 | |||
| 17 | return $path . $folder; |
||
| 18 | |||
| 19 | } // End get_path() |
||
| 20 | |||
| 21 | public static function get_url( $path = '' ) { |
||
| 22 | |||
| 23 | $url = trailingslashit( plugins_url( $path, \PodloveSubscribeButton::plugin_file() ) ); |
||
| 24 | |||
| 25 | return $url; |
||
| 26 | |||
| 27 | } // End get_url() |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get plugin basename |
||
| 31 | * |
||
| 32 | * @since 1.0.0 |
||
| 33 | * |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | public static function get_basename() { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 37 | return plugin_basename( \PodloveSubscribeButton::plugin_file() ); |
||
| 38 | } // get_basename() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Check if `Podlove Publisher` is installed + activated |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public static function is_podlove_publisher_active() { |
||
| 46 | if ( is_plugin_active( "podlove-podcasting-plugin-for-wordpress/podlove.php" ) ) { |
||
| 47 | return true; |
||
| 48 | } |
||
| 49 | |||
| 50 | return false; |
||
| 51 | |||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Get button compatible language string. |
||
| 56 | * |
||
| 57 | * Examples: |
||
| 58 | * |
||
| 59 | * language('de'); // => 'de' |
||
| 60 | * language('de_DE'); // => 'de' |
||
| 61 | * language('en_GB'); // => 'en' |
||
| 62 | * |
||
| 63 | * @param string $language language identifier |
||
| 64 | * |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | static function language( $language ) { |
||
| 68 | if ( empty( $language ) ) { |
||
| 69 | $language = get_option( 'WPLANG' ); |
||
| 70 | } |
||
| 71 | |||
| 72 | $lang_code = strtolower(explode('_', $language)[0]); |
||
| 73 | |||
| 74 | if ( in_array( $lang_code, \PodloveSubscribeButton\Defaults::button('language' ) ) ) { |
||
| 75 | return $lang_code; |
||
| 76 | } else { |
||
| 77 | return 'en'; |
||
| 78 | } |
||
| 79 | } |
||
|
0 ignored issues
–
show
|
|||
| 80 | |||
| 81 | public static function for_every_podcast_blog( $callback ) { |
||
| 82 | global $wpdb; |
||
| 83 | |||
| 84 | $plugin = self::get_basename(); |
||
| 85 | $blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
||
| 86 | |||
| 87 | if ( ! is_array( $blogids ) ) |
||
| 88 | return; |
||
| 89 | |||
| 90 | foreach ( $blogids as $blog_id ) { |
||
| 91 | switch_to_blog( $blog_id ); |
||
| 92 | if ( is_plugin_active( $plugin ) ) { |
||
| 93 | $callback(); |
||
| 94 | } |
||
| 95 | restore_current_blog(); |
||
| 96 | } |
||
| 97 | } |
||
|
0 ignored issues
–
show
|
|||
| 98 | |||
| 99 | } // END Class |
||
| 100 |