Plugin Directory

Changeset 3173030


Ignore:
Timestamp:
10/21/2024 03:01:43 PM (17 months ago)
Author:
humix
Message:

Improvements to channel hosting setup process

Location:
humix
Files:
7 edited
8 copied

Legend:

Unmodified
Added
Removed
  • humix/tags/1.5.0/HumixNamespace/Authentication.php

    r3129709 r3173030  
    2323        add_action('rest_api_init', function () {
    2424            register_rest_route(
    25                 'humix/v1',
     25                RestApi::REST_API_BASE,
    2626                '/auth/verify',
    27                 array (
     27                array(
    2828                    'methods' => \WP_REST_SERVER::READABLE,
    29                     'callback' => array (self::class, 'verify_handler'),
     29                    'callback' => array(self::class, 'verify_handler'),
    3030                    'permission_callback' => '__return_true',
    3131                    'show_in_index' => false
     
    3333            );
    3434        });
    35 
    3635    }
    3736
     
    151150    }
    152151
    153     public function is_humix_direct_domain($token) {
     152    public function is_humix_direct_domain($token)
     153    {
    154154        // we have to cache result as string since an empty cache returns false, so we can't differentiate between false and not cached
    155155        $cached_result_as_str = get_transient(self::IS_HUMIX_DIRECT);
  • humix/tags/1.5.0/HumixNamespace/Channels.php

    r3129709 r3173030  
    1010    const MY_CHANNELS_CACHE_KEY = "humix_plugin:my_channels";
    1111    const MY_CHANNELS_CACHE_TTL = 12 * 3600; // 12 hours
    12     const MIDDLETON_REWRITE_RULE_REGEX = '^(humix|beardeddragon|ezoimgfmt)/?(.*)?$';
     12    const HOSTING_LIVE_CHECK_ENDPOINT = "_humix_integration_check";
     13    const HOSTING_LIVE_CHECK_RESPONSE = "humix-integration-ok";
     14    const MIDDLETON_REWRITE_RULE_REGEX = '^(humix|beardeddragon|ezoimgfmt|_humix_integration_check)/?(.*)?$';
    1315
    1416    public function update_assigned_channel($token, $new_channel_id)
     
    3133    }
    3234
    33     function remove_assigned_channel($token)
     35    public function remove_assigned_channel($token)
    3436    {
    3537        if ($token === "") {
     
    4143        }
    4244        self::remove_middleton_paths();
     45    }
     46
     47    public function get_assigned_channel_from_publisher_backend($token)
     48    {
     49        if ($token === "") {
     50            throw new \InvalidArgumentException("Token is empty");
     51        }
     52        $response = \HumixNamespace\RequestUtils::publisher_backend_request($token, 'assigned-channel', 'GET');
     53        if (is_wp_error($response)) {
     54            throw new \Exception("Error communicating with publisher backend: " . $response->get_error_message());
     55        }
     56        $body = wp_remote_retrieve_body($response);
     57        if (!$body) {
     58            throw new \Exception("Error empty response from publisher backend");
     59        }
     60        $data = json_decode($body, true);
     61        if (!array_key_exists('data', $data) || !is_array($data['data'])) {
     62            throw new \Exception("Error unexpected response from publisher backend");
     63        }
     64        $assigned_channel_response = $data["data"];
     65        return isset($assigned_channel_response["humixChannelId"]) ? (int) $assigned_channel_response["humixChannelId"] : -1;
    4366    }
    4467
     
    110133        }
    111134
    112         $response = \HumixNamespace\RequestUtils::get_middleton_request($wp_query->query_vars['humix_middleton_path']);
     135        $path = $wp_query->query_vars['humix_middleton_path'];
     136
     137        if ($path === self::HOSTING_LIVE_CHECK_ENDPOINT || $path === self::HOSTING_LIVE_CHECK_ENDPOINT . '/') {
     138            // This is a live check request from humix.com
     139            echo self::HOSTING_LIVE_CHECK_RESPONSE;
     140            exit;
     141        }
     142
     143        $response = \HumixNamespace\RequestUtils::get_middleton_request($path);
    113144        if (is_wp_error($response)) {
    114145            \error_log("Humix Plugin Error: Failed to load Humix Channel from middleton: " . $response->get_error_message());
     
    128159        $output = wp_remote_retrieve_body($response);
    129160        echo $output;
    130         exit; // Stop further processing
     161        exit;
    131162    }
    132163
  • humix/tags/1.5.0/HumixNamespace/Settings.php

    r3144450 r3173030  
    11<?php
    22
    3 Namespace HumixNamespace;
    4 
    5 class Settings 
     3namespace HumixNamespace;
     4
     5class Settings
    66{
    77
    8     const PAGE_TITLE = 'Humix Settings';
    9     const MENU_TITLE = 'Humix';
    10     const CAPABILITY = 'manage_options';
    11     const MENU_SLUG = 'humix_settings';
    12 
    13     const PREFIX = 'humix_plugin_';
    14     const GROUP_SUFFIX = '_group';
    15     const SECTION_SUFFIX = '_section';
    16     const PAGE_SUFFIX = '_page';
    17 
    18     const CHANNEL_SETTINGS = self::PREFIX.'channel_settings';
    19     const CHANNEL_SETTINGS_GROUP = self::CHANNEL_SETTINGS.self::GROUP_SUFFIX;
    20     const CHANNEL_SETTINGS_SECTION = self::CHANNEL_SETTINGS.self::SECTION_SUFFIX;
    21     const CHANNEL_SETTINGS_PAGE = self::CHANNEL_SETTINGS.self::PAGE_SUFFIX;
    22     const ASSIGNED_CHANNEL_ID_OPTION = self::PREFIX.'assigned_channel_id';
    23    
    24     const ADSTXT_MANAGER_SETTINGS = self::PREFIX.'adstxt_manager';
    25     const ADSTXT_MANAGER_SETTINGS_GROUP = self::ADSTXT_MANAGER_SETTINGS.self::GROUP_SUFFIX;
    26     const ADSTXT_MANAGER_SETTINGS_SECTION = self::ADSTXT_MANAGER_SETTINGS.self::SECTION_SUFFIX;
    27     const ADSTXT_MANAGE_SETTINGS_PAGE = self::ADSTXT_MANAGER_SETTINGS.self::PAGE_SUFFIX;
    28     const ADSTXT_MANAGER_ID_OPTION = self::PREFIX.'adxtxt_manager_id';
    29 
    30     const INSERT_ON_ALL_PAGES_OPTION = self::PREFIX.'insert_on_all_pages';
    31     const VIDEO_INSERT_SETTINGS = self::PREFIX.'video_insert_settings';
    32     const VIDEO_INSERT_SETTINGS_GROUP = self::VIDEO_INSERT_SETTINGS.self::GROUP_SUFFIX;
    33     const VIDEO_INSERT_SETTINGS_SECTION = self::VIDEO_INSERT_SETTINGS.self::SECTION_SUFFIX;
    34     const VIDEO_INSERT_SETTINGS_PAGE = self::VIDEO_INSERT_SETTINGS.self::PAGE_SUFFIX;
    35 
    36     public static function get_assigned_channel_id() {
    37         return (int) \get_option(self::ASSIGNED_CHANNEL_ID_OPTION, -1);
    38     }
    39 
    40     public static function get_adstxt_manager_id() {
    41         return (int) \get_option(self::ADSTXT_MANAGER_ID_OPTION, -1);
    42     }
    43 
    44     public static function get_insert_on_all_pages() {
     8    const PAGE_TITLE = 'Humix Settings';
     9    const MENU_TITLE = 'Humix';
     10    const CAPABILITY = 'manage_options';
     11    const MENU_SLUG = 'humix_settings';
     12
     13    const PREFIX = 'humix_plugin_';
     14    const GROUP_SUFFIX = '_group';
     15    const SECTION_SUFFIX = '_section';
     16    const PAGE_SUFFIX = '_page';
     17
     18    const CHANNEL_SETTINGS = self::PREFIX . 'channel_settings';
     19    const CHANNEL_SETTINGS_GROUP = self::CHANNEL_SETTINGS . self::GROUP_SUFFIX;
     20    const CHANNEL_SETTINGS_SECTION = self::CHANNEL_SETTINGS . self::SECTION_SUFFIX;
     21    const CHANNEL_SETTINGS_PAGE = self::CHANNEL_SETTINGS . self::PAGE_SUFFIX;
     22    const ASSIGNED_CHANNEL_ID_OPTION = self::PREFIX . 'assigned_channel_id';
     23
     24    const ADSTXT_MANAGER_SETTINGS = self::PREFIX . 'adstxt_manager';
     25    const ADSTXT_MANAGER_SETTINGS_GROUP = self::ADSTXT_MANAGER_SETTINGS . self::GROUP_SUFFIX;
     26    const ADSTXT_MANAGER_SETTINGS_SECTION = self::ADSTXT_MANAGER_SETTINGS . self::SECTION_SUFFIX;
     27    const ADSTXT_MANAGE_SETTINGS_PAGE = self::ADSTXT_MANAGER_SETTINGS . self::PAGE_SUFFIX;
     28    const ADSTXT_MANAGER_ID_OPTION = self::PREFIX . 'adxtxt_manager_id';
     29
     30    const INSERT_ON_ALL_PAGES_OPTION = self::PREFIX . 'insert_on_all_pages';
     31    const VIDEO_INSERT_SETTINGS = self::PREFIX . 'video_insert_settings';
     32    const VIDEO_INSERT_SETTINGS_GROUP = self::VIDEO_INSERT_SETTINGS . self::GROUP_SUFFIX;
     33    const VIDEO_INSERT_SETTINGS_SECTION = self::VIDEO_INSERT_SETTINGS . self::SECTION_SUFFIX;
     34    const VIDEO_INSERT_SETTINGS_PAGE = self::VIDEO_INSERT_SETTINGS . self::PAGE_SUFFIX;
     35
     36    public static function get_assigned_channel_id()
     37    {
     38        return (int) \get_option(self::ASSIGNED_CHANNEL_ID_OPTION, -1);
     39    }
     40
     41    public static function update_assigned_channel_id($val)
     42    {
     43        $val = (int) $val;
     44        if ($val === 0 || $val < -1) {
     45            throw new \InvalidArgumentException("Invalid channel ID supplied");
     46        }
     47        \update_option(self::ASSIGNED_CHANNEL_ID_OPTION, $val);
     48        if ($val > 0) {
     49            (new \HumixNamespace\Channels())->setup_middleton_paths();
     50        } else {
     51            (new \HumixNamespace\Channels())->remove_middleton_paths();
     52        }
     53    }
     54
     55    public static function get_adstxt_manager_id()
     56    {
     57        return (int) \get_option(self::ADSTXT_MANAGER_ID_OPTION, -1);
     58    }
     59
     60    public static function get_insert_on_all_pages()
     61    {
    4562        return (bool) \get_option(self::INSERT_ON_ALL_PAGES_OPTION, false);
    4663    }
    4764
    48     public static function set_adstxt_redirect() {
     65    public static function set_adstxt_redirect()
     66    {
    4967        if (self::get_adstxt_manager_id() <= 0) {
    5068            return;
     
    5371    }
    5472
    55     public static function adstxt_redirect() {
     73    public static function adstxt_redirect()
     74    {
    5675        global $wp;
    5776        $isAdsTxtRequest = isset($wp->request) && $wp->request === 'ads.txt';
    58         if(!$isAdsTxtRequest) {
     77        if (!$isAdsTxtRequest) {
    5978            return;
    6079        }
     
    6584        $domain = \wp_parse_url(\get_site_url(), PHP_URL_HOST);
    6685        $domain = preg_replace('/^www\./', '', $domain);
    67         \wp_redirect( 'https://srv.adstxtmanager.com/' . $adstxt_manager_id . '/' . $domain, 301 );
     86        \wp_redirect('https://srv.adstxtmanager.com/' . $adstxt_manager_id . '/' . $domain, 301);
    6887        exit();
    6988    }
    7089
    71     public static function add_auto_insert_script_to_head() {
     90    public static function add_auto_insert_script_to_head()
     91    {
    7292        if (!self::get_insert_on_all_pages()) {
    7393            return;
    7494        }
    7595        ?>
    76             <script>(window.humixPlayers = window.humixPlayers || []).push({target: 'autoinsert'});</script>
    77             <script async data-cfasync="false" src='https://www.humix.com/video.js'></script>
    78         <?php
    79     }
    80 
    81     public static function delete_settings() {
     96        <script>(window.humixPlayers = window.humixPlayers || []).push({ target: 'autoinsert', isGenerated: true });</script>
     97        <script async data-cfasync="false" src='https://www.humix.com/video.js'></script>
     98        <?php
     99    }
     100
     101    public static function delete_settings()
     102    {
    82103        $pluginSettings = array(
    83104            self::ASSIGNED_CHANNEL_ID_OPTION,
     
    94115    }
    95116
    96     public static function show_settings_page() {
    97         // For now, we only need to show the settings page if the domain is a Humix Direct domain.
    98         $auth = new \HumixNamespace\Authentication();
    99         $token = $auth->get_token_from_publisher_backend();
    100         $is_humix_direct_domain = false;
    101         try {
     117    public static function show_settings_page()
     118    {
     119        // For now, we only need to show the settings page if the domain is a Humix Direct domain.
     120        $auth = new \HumixNamespace\Authentication();
     121        $token = $auth->get_token_from_publisher_backend();
     122        $is_humix_direct_domain = false;
     123        try {
    102124            // note: this will now return true if the domain is SA integrated or whitelisted as a test/demo domain
    103             $is_humix_direct_domain = $auth->is_humix_direct_domain($token);
    104         } catch (\InvalidArgumentException $ae) {
    105             \error_log("Humix Plugin Error: Invalid Token supplied from Authentication Service");
    106             return false;
    107         } catch (\Exception $e) {
    108             \error_log("Humix Plugin Error: " . $e->getMessage());
    109             return false;
    110         }
    111 
    112         return $is_humix_direct_domain;
    113     }
    114 
    115     public static function init_settings_page() {
    116         if(!self::show_settings_page()) {
     125            $is_humix_direct_domain = $auth->is_humix_direct_domain($token);
     126        } catch (\InvalidArgumentException $ae) {
     127            \error_log("Humix Plugin Error: Invalid Token supplied from Authentication Service");
     128            return false;
     129        } catch (\Exception $e) {
     130            \error_log("Humix Plugin Error: " . $e->getMessage());
     131            return false;
     132        }
     133
     134        return $is_humix_direct_domain;
     135    }
     136
     137    public static function init_settings_page()
     138    {
     139        if (!self::show_settings_page()) {
    117140            // for non Humix Direct domains we do not show the settings page since they are all domain-specific
    118141            return;
    119142        }
    120         \add_options_page(self::PAGE_TITLE, self::MENU_TITLE, self::CAPABILITY, self::MENU_SLUG,  array(self::class, 'humix_plugin_options_page'));
    121         \add_action('admin_init', array(self::class, 'humix_plugin_settings_init'));
    122     }
    123 
    124     public static function add_plugin_settings_link($links) {
    125         if(!self::show_settings_page()) {
     143        \add_options_page(self::PAGE_TITLE, self::MENU_TITLE, self::CAPABILITY, self::MENU_SLUG, array(self::class, 'humix_plugin_options_page'));
     144        \add_action('admin_init', array(self::class, 'humix_plugin_settings_init'));
     145    }
     146
     147    public static function add_plugin_settings_link($links)
     148    {
     149        if (!self::show_settings_page()) {
    126150            // for non Humix Direct domains we do not show the settings page since they are all domain-specific
    127151            return $links;
    128152        }
    129153        $humix_direct_link = '<a href="https://app.humix.com/site/" target="_blank">Humix Dashboard</a>';
    130         array_unshift($links, $humix_direct_link);
    131         $settings_link = '<a href="options-general.php?page='.self::MENU_SLUG.'">Settings</a>';
    132         array_unshift($links, $settings_link);
    133         return $links;
    134     }
    135 
    136     public static function humix_plugin_settings_init()
    137     {
    138         // video insert settings tab
     154        array_unshift($links, $humix_direct_link);
     155        $settings_link = '<a href="options-general.php?page=' . self::MENU_SLUG . '">Settings</a>';
     156        array_unshift($links, $settings_link);
     157        return $links;
     158    }
     159
     160    public static function humix_plugin_settings_init()
     161    {
     162        // video insert settings tab
    139163        \register_setting(self::VIDEO_INSERT_SETTINGS_GROUP, self::INSERT_ON_ALL_PAGES_OPTION);
    140164        \add_settings_section(self::VIDEO_INSERT_SETTINGS_SECTION, null, null, self::VIDEO_INSERT_SETTINGS_PAGE);
    141165        \add_settings_field(self::INSERT_ON_ALL_PAGES_OPTION, '', array(self::class, 'render_insert_on_all_pages_option'), self::VIDEO_INSERT_SETTINGS_PAGE, self::VIDEO_INSERT_SETTINGS_SECTION);
    142        
     166
    143167        // channel settings tab
    144         \register_setting(self::CHANNEL_SETTINGS_GROUP, self::ASSIGNED_CHANNEL_ID_OPTION);
    145         \add_settings_section(self::CHANNEL_SETTINGS_SECTION, null, null, self::CHANNEL_SETTINGS_PAGE);
    146         \add_settings_field(self::ASSIGNED_CHANNEL_ID_OPTION, 'Channel', array(self::class, 'render_assigned_channel_id_option'), self::CHANNEL_SETTINGS_PAGE, self::CHANNEL_SETTINGS_SECTION);
    147         \add_action('pre_update_option_'.self::ASSIGNED_CHANNEL_ID_OPTION, array(self::class, 'on_assigned_channel_id_option_change'), 10, 3);
    148 
    149         // ads.txt manager settings tab
    150         \register_setting(self::ADSTXT_MANAGER_SETTINGS_GROUP, self::ADSTXT_MANAGER_ID_OPTION);
    151         \add_settings_section(self::ADSTXT_MANAGER_SETTINGS_SECTION, null, null, self::ADSTXT_MANAGE_SETTINGS_PAGE);
    152         \add_settings_field(self::ADSTXT_MANAGER_ID_OPTION, 'ID Number',  array(self::class, 'render_adstxt_manager_id_option'), self::ADSTXT_MANAGE_SETTINGS_PAGE, self::ADSTXT_MANAGER_SETTINGS_SECTION);
    153         \add_action('pre_update_option_'.self::ADSTXT_MANAGER_ID_OPTION, array(self::class, 'on_adstxt_manager_id_option_change'), 10, 3);
    154     }
    155 
    156     public static function is_using_plain_permalinks() {
    157         global $wp_rewrite;
     168        \register_setting(self::CHANNEL_SETTINGS_GROUP, self::ASSIGNED_CHANNEL_ID_OPTION);
     169        \add_settings_section(self::CHANNEL_SETTINGS_SECTION, null, null, self::CHANNEL_SETTINGS_PAGE);
     170        \add_settings_field(self::ASSIGNED_CHANNEL_ID_OPTION, 'Channel', array(self::class, 'render_assigned_channel_id_option'), self::CHANNEL_SETTINGS_PAGE, self::CHANNEL_SETTINGS_SECTION);
     171        \add_action('pre_update_option_' . self::ASSIGNED_CHANNEL_ID_OPTION, array(self::class, 'on_assigned_channel_id_option_change'), 10, 3);
     172
     173        // ads.txt manager settings tab
     174        \register_setting(self::ADSTXT_MANAGER_SETTINGS_GROUP, self::ADSTXT_MANAGER_ID_OPTION);
     175        \add_settings_section(self::ADSTXT_MANAGER_SETTINGS_SECTION, null, null, self::ADSTXT_MANAGE_SETTINGS_PAGE);
     176        \add_settings_field(self::ADSTXT_MANAGER_ID_OPTION, 'ID Number', array(self::class, 'render_adstxt_manager_id_option'), self::ADSTXT_MANAGE_SETTINGS_PAGE, self::ADSTXT_MANAGER_SETTINGS_SECTION);
     177        \add_action('pre_update_option_' . self::ADSTXT_MANAGER_ID_OPTION, array(self::class, 'on_adstxt_manager_id_option_change'), 10, 3);
     178    }
     179
     180    public static function is_using_plain_permalinks()
     181    {
     182        global $wp_rewrite;
    158183        return !$wp_rewrite->using_permalinks();
    159184    }
    160185
    161     public static function show_permalinks_unsupported_notice() {
     186    public static function show_permalinks_unsupported_notice()
     187    {
    162188        ?>
    163189        <div id="setting-error-permalinks_unsupported" class="notice notice-error settings-error">
    164             <p><strong>Notice:</strong> "Plain" permalinks structure is not supported for Humix Channel and Ads.txt features, please update your permalinks structure to use these features</p>
     190            <p><strong>Notice:</strong> "Plain" permalinks structure is not supported for Humix Channel and Ads.txt features,
     191                please update your permalinks structure to use these features</p>
    165192        </div>
    166193        <?php
     
    168195
    169196    const VIDEO_INSERT_SETTINGS_TAB = 'video_insert_settings';
    170     const CHANNEL_SETTINGS_TAB = 'channel_settings';
    171     const ADSTXT_SETTINGS_TAB = 'adstxt_settings';
    172     const DEFAULT_SELECTED_TAB = self::VIDEO_INSERT_SETTINGS_TAB;
    173 
    174     public static function humix_plugin_options_page() {
    175         if(self::is_using_plain_permalinks()) {
     197    const CHANNEL_SETTINGS_TAB = 'channel_settings';
     198    const ADSTXT_SETTINGS_TAB = 'adstxt_settings';
     199    const DEFAULT_SELECTED_TAB = self::VIDEO_INSERT_SETTINGS_TAB;
     200
     201    public static function humix_plugin_options_page()
     202    {
     203        if (self::is_using_plain_permalinks()) {
    176204            // we do not support plain permalinks for the settings features
    177205            self::show_permalinks_unsupported_notice();
    178206        }
    179     ?>
    180     <div class="wrap">
    181         <p>
    182             <img alt="Humix Logo" src="https://assets.humix.com/full_humix_logo.png" />
    183         </p>
    184         <?php
    185         $active_tab = self::DEFAULT_SELECTED_TAB;
    186         $tmp_active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
    187         if (in_array($tmp_active_tab, array(self::CHANNEL_SETTINGS_TAB, self::ADSTXT_SETTINGS_TAB))) {
    188             $active_tab = $tmp_active_tab;
    189         }
    190         ?>
    191         <h2 class="nav-tab-wrapper">
    192             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::VIDEO_INSERT_SETTINGS_TAB ?>"
    193             class="nav-tab <?php echo $active_tab == self::VIDEO_INSERT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Video Insert Settings</a>
    194             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::CHANNEL_SETTINGS_TAB ?>"
    195             class="nav-tab <?php echo $active_tab == self::CHANNEL_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Channel Settings</a>
    196             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::ADSTXT_SETTINGS_TAB ?>"
    197             class="nav-tab <?php echo $active_tab == self::ADSTXT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Ads.txt Manager</a>
    198 
    199 
    200             <a href="https://support.ezoic.com/kb/category/video-humix-studio" target="_blank" class="nav-tab" style="float: right;">
    201                 Help Center
    202             </a>
    203             <a href="https://login.humix.com/" target="_blank" class="nav-tab" style="float: right;">
    204                 Humix Dashboard
    205             </a>
    206         </h2>
    207         <?php
    208         switch($active_tab) {
    209             case self::VIDEO_INSERT_SETTINGS_TAB:
    210                 self::render_video_insert_settings_tab();
    211                 break;
    212             case self::CHANNEL_SETTINGS_TAB:
    213                 self::render_channel_settings_tab();
    214                 break;
    215             case self::ADSTXT_SETTINGS_TAB:
    216                 self::render_adstxt_manager_settings_tab();
    217                 break;
    218             default:
    219                 self::render_video_insert_settings_tab();
    220                 break;
    221         }
    222         ?>
    223     </div>
    224     <?php
    225     }
    226 
    227     public static function render_video_insert_settings_tab() {
     207        ?>
     208        <div class="wrap">
     209            <p>
     210                <img alt="Humix Logo" src="https://assets.humix.com/full_humix_logo.png" />
     211            </p>
     212            <?php
     213            $active_tab = self::DEFAULT_SELECTED_TAB;
     214            $tmp_active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
     215            if (in_array($tmp_active_tab, array(self::CHANNEL_SETTINGS_TAB, self::ADSTXT_SETTINGS_TAB))) {
     216                $active_tab = $tmp_active_tab;
     217            }
     218            ?>
     219            <h2 class="nav-tab-wrapper">
     220                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::VIDEO_INSERT_SETTINGS_TAB ?>"
     221                    class="nav-tab <?php echo $active_tab == self::VIDEO_INSERT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Video
     222                    Insert Settings</a>
     223                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::CHANNEL_SETTINGS_TAB ?>"
     224                    class="nav-tab <?php echo $active_tab == self::CHANNEL_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Channel
     225                    Settings</a>
     226                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::ADSTXT_SETTINGS_TAB ?>"
     227                    class="nav-tab <?php echo $active_tab == self::ADSTXT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Ads.txt
     228                    Manager</a>
     229
     230
     231                <a href="https://support.ezoic.com/kb/category/video-humix-studio" target="_blank" class="nav-tab"
     232                    style="float: right;">
     233                    Help Center
     234                </a>
     235                <a href="https://login.humix.com/" target="_blank" class="nav-tab" style="float: right;">
     236                    Humix Dashboard
     237                </a>
     238            </h2>
     239            <?php
     240            switch ($active_tab) {
     241                case self::VIDEO_INSERT_SETTINGS_TAB:
     242                    self::render_video_insert_settings_tab();
     243                    break;
     244                case self::CHANNEL_SETTINGS_TAB:
     245                    self::render_channel_settings_tab();
     246                    break;
     247                case self::ADSTXT_SETTINGS_TAB:
     248                    self::render_adstxt_manager_settings_tab();
     249                    break;
     250                default:
     251                    self::render_video_insert_settings_tab();
     252                    break;
     253            }
     254            ?>
     255        </div>
     256    <?php
     257    }
     258
     259    public static function render_video_insert_settings_tab()
     260    {
    228261        ?>
    229262        <div class="wrap">
     
    231264            <p class="notice notice-info" style="padding: 15px;">
    232265                Automatically insert videos on all pages in this site.
    233                 <br/>
    234                 To configure the behavior and placement of the auto-inserted videos, visit the <a href="https://app.humix.com/site/settings/content-settings" target="_blank">Humix Dashboard</a>.
     266                <br />
     267                To configure the behavior and placement of the auto-inserted videos, visit the <a
     268                    href="https://app.humix.com/site/settings/content-settings" target="_blank">Humix Dashboard</a>.
    235269            </p>
    236270            <form action="options.php" method="post">
     
    252286            <h2>Channel Settings</h2>
    253287            <p class="notice notice-info" style="padding: 15px;">
    254                 Select a channel from your account below to display on this site at <a href="<?php echo $channel_page; ?>" target="_blank"><?php echo $channel_page; ?></a>
     288                Select a channel from your account below to display on this site at <a href="<?php echo $channel_page; ?>"
     289                    target="_blank"><?php echo $channel_page; ?></a>
    255290            </p>
    256291            <form action="options.php" method="post">
     
    274309                <br>
    275310                <br>
    276                 If you are setting up via the Humix dashboard, you can put in <code>70772</code> as the ID. If you created an account with <a href="https://www.adstxtmanager.com/" target="_blank">adstxtmanager.com</a>, click <a href="https://www.adstxtmanager.com/" target="_blank">here</a> to login and access your ID.
     311                If you are setting up via the Humix dashboard, you can put in <code>70772</code> as the ID. If you created an
     312                account with <a href="https://www.adstxtmanager.com/" target="_blank">adstxtmanager.com</a>, click <a
     313                    href="https://www.adstxtmanager.com/" target="_blank">here</a> to login and access your ID.
    277314            </p>
    278315            <form action="options.php" method="post">
     
    287324    }
    288325
    289     public static function render_insert_on_all_pages_option(){
    290         ?>
    291             <span style="position: absolute; left: 0; margin: 0 15px;">
    292             <input id="insert-on-all-pages" type="checkbox" name="<?php echo self::INSERT_ON_ALL_PAGES_OPTION; ?>" <?php \checked(self::get_insert_on_all_pages(), true); ?>>
     326    public static function render_insert_on_all_pages_option()
     327    {
     328        ?>
     329        <span style="position: absolute; left: 0; margin: 0 15px;">
     330            <input id="insert-on-all-pages" type="checkbox" name="<?php echo self::INSERT_ON_ALL_PAGES_OPTION; ?>" <?php \checked(self::get_insert_on_all_pages(), true); ?>>
    293331            <label for="insert-on-all-pages">Automatically insert video on all pages</label>
    294             </span>
    295             <br/>
    296         <?php
     332        </span>
     333        <br />
     334        <?php
    297335    }
    298336
    299337    public static function render_assigned_channel_id_option()
    300     {
    301         $auth = new \HumixNamespace\Authentication();
    302         $token = $auth->get_token_from_publisher_backend();
    303         $channels = [];
     338    {
     339        $auth = new \HumixNamespace\Authentication();
     340        $token = $auth->get_token_from_publisher_backend();
     341        $channels = [];
    304342        $load_channels_err = false;
    305         try {
    306             $channels = (new \HumixNamespace\Channels())->get_channels($token);
    307         } catch (\Exception $e) {
    308             \error_log("Humix Plugin Error: Failed to load channels: " . $e->getMessage());
    309             $load_channels_err = true;
    310         }
     343        try {
     344            $channels = (new \HumixNamespace\Channels())->get_channels($token);
     345        } catch (\Exception $e) {
     346            \error_log("Humix Plugin Error: Failed to load channels: " . $e->getMessage());
     347            $load_channels_err = true;
     348        }
    311349
    312350        if ($load_channels_err || empty($channels)) {
    313351            ?>
    314             <div id="setting-error-api_error" class="notice notice-error settings-error">
    315                 <p><strong>Failed to load your channels from your account. Please refresh the page and try again.</strong></p>
    316             </div>
    317             <?php
    318             return;
    319         }
    320 
    321         $selected_channel_id = self::get_assigned_channel_id();
    322         ?>
    323         <select name="<?php echo self::ASSIGNED_CHANNEL_ID_OPTION; ?>">
    324             <option value="-1" <?php \selected($selected_channel_id, -1); ?>>
    325                 <?php
    326                 echo (int) $selected_channel_id === -1 ? "Select a channel" : "Remove channel from this site";
    327                 ?>
    328             </option>
    329             <?php foreach ($channels as $channel): ?>
    330                 <option value="<?php echo \esc_attr($channel['humixChannelId']); ?>" <?php \selected($selected_channel_id, $channel['humixChannelId']); ?>>
    331                     <?php echo \esc_html($channel['name']); ?>
    332                 </option>
    333             <?php endforeach; ?>
    334         </select>
    335         <?php
    336     }
     352            <div id="setting-error-api_error" class="notice notice-error settings-error">
     353                <p><strong>Failed to load your channels from your account. Please refresh the page and try again.</strong></p>
     354            </div>
     355            <?php
     356            return;
     357        }
     358
     359        $selected_channel_id = self::get_assigned_channel_id();
     360        ?>
     361        <select name="<?php echo self::ASSIGNED_CHANNEL_ID_OPTION; ?>">
     362            <option value="-1" <?php \selected($selected_channel_id, -1); ?>>
     363                <?php
     364                echo (int) $selected_channel_id === -1 ? "Select a channel" : "Remove channel from this site";
     365                ?>
     366            </option>
     367            <?php foreach ($channels as $channel): ?>
     368                <option value="<?php echo \esc_attr($channel['humixChannelId']); ?>" <?php \selected($selected_channel_id, $channel['humixChannelId']); ?>>
     369                    <?php echo \esc_html($channel['name']); ?>
     370                </option>
     371            <?php endforeach; ?>
     372        </select>
     373        <?php
     374    }
    337375
    338376    public static function render_adstxt_manager_id_option()
    339377    {
    340378        $selected_option = self::get_adstxt_manager_id()
    341         ?>
    342         <input name="<?php echo self::ADSTXT_MANAGER_ID_OPTION; ?>" class="regular-text code" placeholder="Enter your Ads.txt Manager ID..."
    343             <?php
    344                 if($selected_option > 0) {
    345                     echo 'value="' . $selected_option . '"';
    346                 }
    347379            ?>
    348         ></input>
     380        <input name="<?php echo self::ADSTXT_MANAGER_ID_OPTION; ?>" class="regular-text code"
     381            placeholder="Enter your Ads.txt Manager ID..." <?php
     382            if ($selected_option > 0) {
     383                echo 'value="' . $selected_option . '"';
     384            }
     385            ?>></input>
    349386        <?php
    350387    }
     
    388425
    389426        // Allow user to pass empty string (or 0) to effectively clear out the value
    390         if($new_adstxt_manager_id === "") {
     427        if ($new_adstxt_manager_id === "") {
    391428            $new_adstxt_manager_id = 0;
    392429        }
  • humix/tags/1.5.0/README.txt

    r3144450 r3173030  
    44Tags: humix, video, embed, network
    55Requires at least: 5.8.0
    6 Tested up to: 6.5
     6Tested up to: 6.6
    77Requires PHP: 7.0
    8 Stable tag: 1.4.1
     8Stable tag: 1.5.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2323
    2424== Changelog ==
     25= 1.5.0 =
     26* Improvements to channel hosting setup process
     27
    2528= 1.4.1 =
    2629* Changed adstxtmanager ID
  • humix/tags/1.5.0/humix.php

    r3144450 r3173030  
    55require "HumixNamespace/Channels.php";
    66require "HumixNamespace/Settings.php";
     7require "HumixNamespace/RestApi.php";
    78
    89/**
     
    1516 *
    1617 * @link              https://www.humix.com/
    17  * @since             1.4.1
     18 * @since             1.5.0
    1819 * @package           Humix
    1920 *
     
    2223 * Plugin URI:        https://wordpress.org/plugins/humix
    2324 * Description:       Humix allows you to easily embed videos to your site from the Humix Network.
    24  * Version:           1.4.1
     25 * Version:           1.5.0
    2526 * Author:            Humix
    2627 * Author URI:        https://www.humix.com/
     
    3940 * Rename this for your plugin and update it as you release new versions.
    4041 */
    41 define('HUMIX_VERSION', '1.4.1');
     42define('HUMIX_VERSION', '1.5.0');
    4243
    4344global $EZHX_REGEX;
     
    6263    \HumixNamespace\Authentication::register();
    6364
     65    // register API endpoitns
     66    \HumixNamespace\RestApi::register();
     67
    6468    // handle rewrite rules for middleton requests appropriately
    6569    $assigned_humix_channel_id = \HumixNamespace\Settings::get_assigned_channel_id();
     
    7680    }
    7781
     82    // handle insert videos on all pages if enabled
    7883    $insert_on_all_pages = \HumixNamespace\Settings::get_insert_on_all_pages();
    7984    if ($insert_on_all_pages) {
  • humix/trunk/HumixNamespace/Authentication.php

    r3129709 r3173030  
    2323        add_action('rest_api_init', function () {
    2424            register_rest_route(
    25                 'humix/v1',
     25                RestApi::REST_API_BASE,
    2626                '/auth/verify',
    27                 array (
     27                array(
    2828                    'methods' => \WP_REST_SERVER::READABLE,
    29                     'callback' => array (self::class, 'verify_handler'),
     29                    'callback' => array(self::class, 'verify_handler'),
    3030                    'permission_callback' => '__return_true',
    3131                    'show_in_index' => false
     
    3333            );
    3434        });
    35 
    3635    }
    3736
     
    151150    }
    152151
    153     public function is_humix_direct_domain($token) {
     152    public function is_humix_direct_domain($token)
     153    {
    154154        // we have to cache result as string since an empty cache returns false, so we can't differentiate between false and not cached
    155155        $cached_result_as_str = get_transient(self::IS_HUMIX_DIRECT);
  • humix/trunk/HumixNamespace/Channels.php

    r3129709 r3173030  
    1010    const MY_CHANNELS_CACHE_KEY = "humix_plugin:my_channels";
    1111    const MY_CHANNELS_CACHE_TTL = 12 * 3600; // 12 hours
    12     const MIDDLETON_REWRITE_RULE_REGEX = '^(humix|beardeddragon|ezoimgfmt)/?(.*)?$';
     12    const HOSTING_LIVE_CHECK_ENDPOINT = "_humix_integration_check";
     13    const HOSTING_LIVE_CHECK_RESPONSE = "humix-integration-ok";
     14    const MIDDLETON_REWRITE_RULE_REGEX = '^(humix|beardeddragon|ezoimgfmt|_humix_integration_check)/?(.*)?$';
    1315
    1416    public function update_assigned_channel($token, $new_channel_id)
     
    3133    }
    3234
    33     function remove_assigned_channel($token)
     35    public function remove_assigned_channel($token)
    3436    {
    3537        if ($token === "") {
     
    4143        }
    4244        self::remove_middleton_paths();
     45    }
     46
     47    public function get_assigned_channel_from_publisher_backend($token)
     48    {
     49        if ($token === "") {
     50            throw new \InvalidArgumentException("Token is empty");
     51        }
     52        $response = \HumixNamespace\RequestUtils::publisher_backend_request($token, 'assigned-channel', 'GET');
     53        if (is_wp_error($response)) {
     54            throw new \Exception("Error communicating with publisher backend: " . $response->get_error_message());
     55        }
     56        $body = wp_remote_retrieve_body($response);
     57        if (!$body) {
     58            throw new \Exception("Error empty response from publisher backend");
     59        }
     60        $data = json_decode($body, true);
     61        if (!array_key_exists('data', $data) || !is_array($data['data'])) {
     62            throw new \Exception("Error unexpected response from publisher backend");
     63        }
     64        $assigned_channel_response = $data["data"];
     65        return isset($assigned_channel_response["humixChannelId"]) ? (int) $assigned_channel_response["humixChannelId"] : -1;
    4366    }
    4467
     
    110133        }
    111134
    112         $response = \HumixNamespace\RequestUtils::get_middleton_request($wp_query->query_vars['humix_middleton_path']);
     135        $path = $wp_query->query_vars['humix_middleton_path'];
     136
     137        if ($path === self::HOSTING_LIVE_CHECK_ENDPOINT || $path === self::HOSTING_LIVE_CHECK_ENDPOINT . '/') {
     138            // This is a live check request from humix.com
     139            echo self::HOSTING_LIVE_CHECK_RESPONSE;
     140            exit;
     141        }
     142
     143        $response = \HumixNamespace\RequestUtils::get_middleton_request($path);
    113144        if (is_wp_error($response)) {
    114145            \error_log("Humix Plugin Error: Failed to load Humix Channel from middleton: " . $response->get_error_message());
     
    128159        $output = wp_remote_retrieve_body($response);
    129160        echo $output;
    130         exit; // Stop further processing
     161        exit;
    131162    }
    132163
  • humix/trunk/HumixNamespace/Settings.php

    r3144450 r3173030  
    11<?php
    22
    3 Namespace HumixNamespace;
    4 
    5 class Settings 
     3namespace HumixNamespace;
     4
     5class Settings
    66{
    77
    8     const PAGE_TITLE = 'Humix Settings';
    9     const MENU_TITLE = 'Humix';
    10     const CAPABILITY = 'manage_options';
    11     const MENU_SLUG = 'humix_settings';
    12 
    13     const PREFIX = 'humix_plugin_';
    14     const GROUP_SUFFIX = '_group';
    15     const SECTION_SUFFIX = '_section';
    16     const PAGE_SUFFIX = '_page';
    17 
    18     const CHANNEL_SETTINGS = self::PREFIX.'channel_settings';
    19     const CHANNEL_SETTINGS_GROUP = self::CHANNEL_SETTINGS.self::GROUP_SUFFIX;
    20     const CHANNEL_SETTINGS_SECTION = self::CHANNEL_SETTINGS.self::SECTION_SUFFIX;
    21     const CHANNEL_SETTINGS_PAGE = self::CHANNEL_SETTINGS.self::PAGE_SUFFIX;
    22     const ASSIGNED_CHANNEL_ID_OPTION = self::PREFIX.'assigned_channel_id';
    23    
    24     const ADSTXT_MANAGER_SETTINGS = self::PREFIX.'adstxt_manager';
    25     const ADSTXT_MANAGER_SETTINGS_GROUP = self::ADSTXT_MANAGER_SETTINGS.self::GROUP_SUFFIX;
    26     const ADSTXT_MANAGER_SETTINGS_SECTION = self::ADSTXT_MANAGER_SETTINGS.self::SECTION_SUFFIX;
    27     const ADSTXT_MANAGE_SETTINGS_PAGE = self::ADSTXT_MANAGER_SETTINGS.self::PAGE_SUFFIX;
    28     const ADSTXT_MANAGER_ID_OPTION = self::PREFIX.'adxtxt_manager_id';
    29 
    30     const INSERT_ON_ALL_PAGES_OPTION = self::PREFIX.'insert_on_all_pages';
    31     const VIDEO_INSERT_SETTINGS = self::PREFIX.'video_insert_settings';
    32     const VIDEO_INSERT_SETTINGS_GROUP = self::VIDEO_INSERT_SETTINGS.self::GROUP_SUFFIX;
    33     const VIDEO_INSERT_SETTINGS_SECTION = self::VIDEO_INSERT_SETTINGS.self::SECTION_SUFFIX;
    34     const VIDEO_INSERT_SETTINGS_PAGE = self::VIDEO_INSERT_SETTINGS.self::PAGE_SUFFIX;
    35 
    36     public static function get_assigned_channel_id() {
    37         return (int) \get_option(self::ASSIGNED_CHANNEL_ID_OPTION, -1);
    38     }
    39 
    40     public static function get_adstxt_manager_id() {
    41         return (int) \get_option(self::ADSTXT_MANAGER_ID_OPTION, -1);
    42     }
    43 
    44     public static function get_insert_on_all_pages() {
     8    const PAGE_TITLE = 'Humix Settings';
     9    const MENU_TITLE = 'Humix';
     10    const CAPABILITY = 'manage_options';
     11    const MENU_SLUG = 'humix_settings';
     12
     13    const PREFIX = 'humix_plugin_';
     14    const GROUP_SUFFIX = '_group';
     15    const SECTION_SUFFIX = '_section';
     16    const PAGE_SUFFIX = '_page';
     17
     18    const CHANNEL_SETTINGS = self::PREFIX . 'channel_settings';
     19    const CHANNEL_SETTINGS_GROUP = self::CHANNEL_SETTINGS . self::GROUP_SUFFIX;
     20    const CHANNEL_SETTINGS_SECTION = self::CHANNEL_SETTINGS . self::SECTION_SUFFIX;
     21    const CHANNEL_SETTINGS_PAGE = self::CHANNEL_SETTINGS . self::PAGE_SUFFIX;
     22    const ASSIGNED_CHANNEL_ID_OPTION = self::PREFIX . 'assigned_channel_id';
     23
     24    const ADSTXT_MANAGER_SETTINGS = self::PREFIX . 'adstxt_manager';
     25    const ADSTXT_MANAGER_SETTINGS_GROUP = self::ADSTXT_MANAGER_SETTINGS . self::GROUP_SUFFIX;
     26    const ADSTXT_MANAGER_SETTINGS_SECTION = self::ADSTXT_MANAGER_SETTINGS . self::SECTION_SUFFIX;
     27    const ADSTXT_MANAGE_SETTINGS_PAGE = self::ADSTXT_MANAGER_SETTINGS . self::PAGE_SUFFIX;
     28    const ADSTXT_MANAGER_ID_OPTION = self::PREFIX . 'adxtxt_manager_id';
     29
     30    const INSERT_ON_ALL_PAGES_OPTION = self::PREFIX . 'insert_on_all_pages';
     31    const VIDEO_INSERT_SETTINGS = self::PREFIX . 'video_insert_settings';
     32    const VIDEO_INSERT_SETTINGS_GROUP = self::VIDEO_INSERT_SETTINGS . self::GROUP_SUFFIX;
     33    const VIDEO_INSERT_SETTINGS_SECTION = self::VIDEO_INSERT_SETTINGS . self::SECTION_SUFFIX;
     34    const VIDEO_INSERT_SETTINGS_PAGE = self::VIDEO_INSERT_SETTINGS . self::PAGE_SUFFIX;
     35
     36    public static function get_assigned_channel_id()
     37    {
     38        return (int) \get_option(self::ASSIGNED_CHANNEL_ID_OPTION, -1);
     39    }
     40
     41    public static function update_assigned_channel_id($val)
     42    {
     43        $val = (int) $val;
     44        if ($val === 0 || $val < -1) {
     45            throw new \InvalidArgumentException("Invalid channel ID supplied");
     46        }
     47        \update_option(self::ASSIGNED_CHANNEL_ID_OPTION, $val);
     48        if ($val > 0) {
     49            (new \HumixNamespace\Channels())->setup_middleton_paths();
     50        } else {
     51            (new \HumixNamespace\Channels())->remove_middleton_paths();
     52        }
     53    }
     54
     55    public static function get_adstxt_manager_id()
     56    {
     57        return (int) \get_option(self::ADSTXT_MANAGER_ID_OPTION, -1);
     58    }
     59
     60    public static function get_insert_on_all_pages()
     61    {
    4562        return (bool) \get_option(self::INSERT_ON_ALL_PAGES_OPTION, false);
    4663    }
    4764
    48     public static function set_adstxt_redirect() {
     65    public static function set_adstxt_redirect()
     66    {
    4967        if (self::get_adstxt_manager_id() <= 0) {
    5068            return;
     
    5371    }
    5472
    55     public static function adstxt_redirect() {
     73    public static function adstxt_redirect()
     74    {
    5675        global $wp;
    5776        $isAdsTxtRequest = isset($wp->request) && $wp->request === 'ads.txt';
    58         if(!$isAdsTxtRequest) {
     77        if (!$isAdsTxtRequest) {
    5978            return;
    6079        }
     
    6584        $domain = \wp_parse_url(\get_site_url(), PHP_URL_HOST);
    6685        $domain = preg_replace('/^www\./', '', $domain);
    67         \wp_redirect( 'https://srv.adstxtmanager.com/' . $adstxt_manager_id . '/' . $domain, 301 );
     86        \wp_redirect('https://srv.adstxtmanager.com/' . $adstxt_manager_id . '/' . $domain, 301);
    6887        exit();
    6988    }
    7089
    71     public static function add_auto_insert_script_to_head() {
     90    public static function add_auto_insert_script_to_head()
     91    {
    7292        if (!self::get_insert_on_all_pages()) {
    7393            return;
    7494        }
    7595        ?>
    76             <script>(window.humixPlayers = window.humixPlayers || []).push({target: 'autoinsert'});</script>
    77             <script async data-cfasync="false" src='https://www.humix.com/video.js'></script>
    78         <?php
    79     }
    80 
    81     public static function delete_settings() {
     96        <script>(window.humixPlayers = window.humixPlayers || []).push({ target: 'autoinsert', isGenerated: true });</script>
     97        <script async data-cfasync="false" src='https://www.humix.com/video.js'></script>
     98        <?php
     99    }
     100
     101    public static function delete_settings()
     102    {
    82103        $pluginSettings = array(
    83104            self::ASSIGNED_CHANNEL_ID_OPTION,
     
    94115    }
    95116
    96     public static function show_settings_page() {
    97         // For now, we only need to show the settings page if the domain is a Humix Direct domain.
    98         $auth = new \HumixNamespace\Authentication();
    99         $token = $auth->get_token_from_publisher_backend();
    100         $is_humix_direct_domain = false;
    101         try {
     117    public static function show_settings_page()
     118    {
     119        // For now, we only need to show the settings page if the domain is a Humix Direct domain.
     120        $auth = new \HumixNamespace\Authentication();
     121        $token = $auth->get_token_from_publisher_backend();
     122        $is_humix_direct_domain = false;
     123        try {
    102124            // note: this will now return true if the domain is SA integrated or whitelisted as a test/demo domain
    103             $is_humix_direct_domain = $auth->is_humix_direct_domain($token);
    104         } catch (\InvalidArgumentException $ae) {
    105             \error_log("Humix Plugin Error: Invalid Token supplied from Authentication Service");
    106             return false;
    107         } catch (\Exception $e) {
    108             \error_log("Humix Plugin Error: " . $e->getMessage());
    109             return false;
    110         }
    111 
    112         return $is_humix_direct_domain;
    113     }
    114 
    115     public static function init_settings_page() {
    116         if(!self::show_settings_page()) {
     125            $is_humix_direct_domain = $auth->is_humix_direct_domain($token);
     126        } catch (\InvalidArgumentException $ae) {
     127            \error_log("Humix Plugin Error: Invalid Token supplied from Authentication Service");
     128            return false;
     129        } catch (\Exception $e) {
     130            \error_log("Humix Plugin Error: " . $e->getMessage());
     131            return false;
     132        }
     133
     134        return $is_humix_direct_domain;
     135    }
     136
     137    public static function init_settings_page()
     138    {
     139        if (!self::show_settings_page()) {
    117140            // for non Humix Direct domains we do not show the settings page since they are all domain-specific
    118141            return;
    119142        }
    120         \add_options_page(self::PAGE_TITLE, self::MENU_TITLE, self::CAPABILITY, self::MENU_SLUG,  array(self::class, 'humix_plugin_options_page'));
    121         \add_action('admin_init', array(self::class, 'humix_plugin_settings_init'));
    122     }
    123 
    124     public static function add_plugin_settings_link($links) {
    125         if(!self::show_settings_page()) {
     143        \add_options_page(self::PAGE_TITLE, self::MENU_TITLE, self::CAPABILITY, self::MENU_SLUG, array(self::class, 'humix_plugin_options_page'));
     144        \add_action('admin_init', array(self::class, 'humix_plugin_settings_init'));
     145    }
     146
     147    public static function add_plugin_settings_link($links)
     148    {
     149        if (!self::show_settings_page()) {
    126150            // for non Humix Direct domains we do not show the settings page since they are all domain-specific
    127151            return $links;
    128152        }
    129153        $humix_direct_link = '<a href="https://app.humix.com/site/" target="_blank">Humix Dashboard</a>';
    130         array_unshift($links, $humix_direct_link);
    131         $settings_link = '<a href="options-general.php?page='.self::MENU_SLUG.'">Settings</a>';
    132         array_unshift($links, $settings_link);
    133         return $links;
    134     }
    135 
    136     public static function humix_plugin_settings_init()
    137     {
    138         // video insert settings tab
     154        array_unshift($links, $humix_direct_link);
     155        $settings_link = '<a href="options-general.php?page=' . self::MENU_SLUG . '">Settings</a>';
     156        array_unshift($links, $settings_link);
     157        return $links;
     158    }
     159
     160    public static function humix_plugin_settings_init()
     161    {
     162        // video insert settings tab
    139163        \register_setting(self::VIDEO_INSERT_SETTINGS_GROUP, self::INSERT_ON_ALL_PAGES_OPTION);
    140164        \add_settings_section(self::VIDEO_INSERT_SETTINGS_SECTION, null, null, self::VIDEO_INSERT_SETTINGS_PAGE);
    141165        \add_settings_field(self::INSERT_ON_ALL_PAGES_OPTION, '', array(self::class, 'render_insert_on_all_pages_option'), self::VIDEO_INSERT_SETTINGS_PAGE, self::VIDEO_INSERT_SETTINGS_SECTION);
    142        
     166
    143167        // channel settings tab
    144         \register_setting(self::CHANNEL_SETTINGS_GROUP, self::ASSIGNED_CHANNEL_ID_OPTION);
    145         \add_settings_section(self::CHANNEL_SETTINGS_SECTION, null, null, self::CHANNEL_SETTINGS_PAGE);
    146         \add_settings_field(self::ASSIGNED_CHANNEL_ID_OPTION, 'Channel', array(self::class, 'render_assigned_channel_id_option'), self::CHANNEL_SETTINGS_PAGE, self::CHANNEL_SETTINGS_SECTION);
    147         \add_action('pre_update_option_'.self::ASSIGNED_CHANNEL_ID_OPTION, array(self::class, 'on_assigned_channel_id_option_change'), 10, 3);
    148 
    149         // ads.txt manager settings tab
    150         \register_setting(self::ADSTXT_MANAGER_SETTINGS_GROUP, self::ADSTXT_MANAGER_ID_OPTION);
    151         \add_settings_section(self::ADSTXT_MANAGER_SETTINGS_SECTION, null, null, self::ADSTXT_MANAGE_SETTINGS_PAGE);
    152         \add_settings_field(self::ADSTXT_MANAGER_ID_OPTION, 'ID Number',  array(self::class, 'render_adstxt_manager_id_option'), self::ADSTXT_MANAGE_SETTINGS_PAGE, self::ADSTXT_MANAGER_SETTINGS_SECTION);
    153         \add_action('pre_update_option_'.self::ADSTXT_MANAGER_ID_OPTION, array(self::class, 'on_adstxt_manager_id_option_change'), 10, 3);
    154     }
    155 
    156     public static function is_using_plain_permalinks() {
    157         global $wp_rewrite;
     168        \register_setting(self::CHANNEL_SETTINGS_GROUP, self::ASSIGNED_CHANNEL_ID_OPTION);
     169        \add_settings_section(self::CHANNEL_SETTINGS_SECTION, null, null, self::CHANNEL_SETTINGS_PAGE);
     170        \add_settings_field(self::ASSIGNED_CHANNEL_ID_OPTION, 'Channel', array(self::class, 'render_assigned_channel_id_option'), self::CHANNEL_SETTINGS_PAGE, self::CHANNEL_SETTINGS_SECTION);
     171        \add_action('pre_update_option_' . self::ASSIGNED_CHANNEL_ID_OPTION, array(self::class, 'on_assigned_channel_id_option_change'), 10, 3);
     172
     173        // ads.txt manager settings tab
     174        \register_setting(self::ADSTXT_MANAGER_SETTINGS_GROUP, self::ADSTXT_MANAGER_ID_OPTION);
     175        \add_settings_section(self::ADSTXT_MANAGER_SETTINGS_SECTION, null, null, self::ADSTXT_MANAGE_SETTINGS_PAGE);
     176        \add_settings_field(self::ADSTXT_MANAGER_ID_OPTION, 'ID Number', array(self::class, 'render_adstxt_manager_id_option'), self::ADSTXT_MANAGE_SETTINGS_PAGE, self::ADSTXT_MANAGER_SETTINGS_SECTION);
     177        \add_action('pre_update_option_' . self::ADSTXT_MANAGER_ID_OPTION, array(self::class, 'on_adstxt_manager_id_option_change'), 10, 3);
     178    }
     179
     180    public static function is_using_plain_permalinks()
     181    {
     182        global $wp_rewrite;
    158183        return !$wp_rewrite->using_permalinks();
    159184    }
    160185
    161     public static function show_permalinks_unsupported_notice() {
     186    public static function show_permalinks_unsupported_notice()
     187    {
    162188        ?>
    163189        <div id="setting-error-permalinks_unsupported" class="notice notice-error settings-error">
    164             <p><strong>Notice:</strong> "Plain" permalinks structure is not supported for Humix Channel and Ads.txt features, please update your permalinks structure to use these features</p>
     190            <p><strong>Notice:</strong> "Plain" permalinks structure is not supported for Humix Channel and Ads.txt features,
     191                please update your permalinks structure to use these features</p>
    165192        </div>
    166193        <?php
     
    168195
    169196    const VIDEO_INSERT_SETTINGS_TAB = 'video_insert_settings';
    170     const CHANNEL_SETTINGS_TAB = 'channel_settings';
    171     const ADSTXT_SETTINGS_TAB = 'adstxt_settings';
    172     const DEFAULT_SELECTED_TAB = self::VIDEO_INSERT_SETTINGS_TAB;
    173 
    174     public static function humix_plugin_options_page() {
    175         if(self::is_using_plain_permalinks()) {
     197    const CHANNEL_SETTINGS_TAB = 'channel_settings';
     198    const ADSTXT_SETTINGS_TAB = 'adstxt_settings';
     199    const DEFAULT_SELECTED_TAB = self::VIDEO_INSERT_SETTINGS_TAB;
     200
     201    public static function humix_plugin_options_page()
     202    {
     203        if (self::is_using_plain_permalinks()) {
    176204            // we do not support plain permalinks for the settings features
    177205            self::show_permalinks_unsupported_notice();
    178206        }
    179     ?>
    180     <div class="wrap">
    181         <p>
    182             <img alt="Humix Logo" src="https://assets.humix.com/full_humix_logo.png" />
    183         </p>
    184         <?php
    185         $active_tab = self::DEFAULT_SELECTED_TAB;
    186         $tmp_active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
    187         if (in_array($tmp_active_tab, array(self::CHANNEL_SETTINGS_TAB, self::ADSTXT_SETTINGS_TAB))) {
    188             $active_tab = $tmp_active_tab;
    189         }
    190         ?>
    191         <h2 class="nav-tab-wrapper">
    192             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::VIDEO_INSERT_SETTINGS_TAB ?>"
    193             class="nav-tab <?php echo $active_tab == self::VIDEO_INSERT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Video Insert Settings</a>
    194             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::CHANNEL_SETTINGS_TAB ?>"
    195             class="nav-tab <?php echo $active_tab == self::CHANNEL_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Channel Settings</a>
    196             <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::ADSTXT_SETTINGS_TAB ?>"
    197             class="nav-tab <?php echo $active_tab == self::ADSTXT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Ads.txt Manager</a>
    198 
    199 
    200             <a href="https://support.ezoic.com/kb/category/video-humix-studio" target="_blank" class="nav-tab" style="float: right;">
    201                 Help Center
    202             </a>
    203             <a href="https://login.humix.com/" target="_blank" class="nav-tab" style="float: right;">
    204                 Humix Dashboard
    205             </a>
    206         </h2>
    207         <?php
    208         switch($active_tab) {
    209             case self::VIDEO_INSERT_SETTINGS_TAB:
    210                 self::render_video_insert_settings_tab();
    211                 break;
    212             case self::CHANNEL_SETTINGS_TAB:
    213                 self::render_channel_settings_tab();
    214                 break;
    215             case self::ADSTXT_SETTINGS_TAB:
    216                 self::render_adstxt_manager_settings_tab();
    217                 break;
    218             default:
    219                 self::render_video_insert_settings_tab();
    220                 break;
    221         }
    222         ?>
    223     </div>
    224     <?php
    225     }
    226 
    227     public static function render_video_insert_settings_tab() {
     207        ?>
     208        <div class="wrap">
     209            <p>
     210                <img alt="Humix Logo" src="https://assets.humix.com/full_humix_logo.png" />
     211            </p>
     212            <?php
     213            $active_tab = self::DEFAULT_SELECTED_TAB;
     214            $tmp_active_tab = isset($_GET['tab']) ? $_GET['tab'] : '';
     215            if (in_array($tmp_active_tab, array(self::CHANNEL_SETTINGS_TAB, self::ADSTXT_SETTINGS_TAB))) {
     216                $active_tab = $tmp_active_tab;
     217            }
     218            ?>
     219            <h2 class="nav-tab-wrapper">
     220                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::VIDEO_INSERT_SETTINGS_TAB ?>"
     221                    class="nav-tab <?php echo $active_tab == self::VIDEO_INSERT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Video
     222                    Insert Settings</a>
     223                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::CHANNEL_SETTINGS_TAB ?>"
     224                    class="nav-tab <?php echo $active_tab == self::CHANNEL_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Channel
     225                    Settings</a>
     226                <a href="?page=<?php echo self::MENU_SLUG ?>&tab=<?php echo self::ADSTXT_SETTINGS_TAB ?>"
     227                    class="nav-tab <?php echo $active_tab == self::ADSTXT_SETTINGS_TAB ? 'nav-tab-active' : ''; ?>">Ads.txt
     228                    Manager</a>
     229
     230
     231                <a href="https://support.ezoic.com/kb/category/video-humix-studio" target="_blank" class="nav-tab"
     232                    style="float: right;">
     233                    Help Center
     234                </a>
     235                <a href="https://login.humix.com/" target="_blank" class="nav-tab" style="float: right;">
     236                    Humix Dashboard
     237                </a>
     238            </h2>
     239            <?php
     240            switch ($active_tab) {
     241                case self::VIDEO_INSERT_SETTINGS_TAB:
     242                    self::render_video_insert_settings_tab();
     243                    break;
     244                case self::CHANNEL_SETTINGS_TAB:
     245                    self::render_channel_settings_tab();
     246                    break;
     247                case self::ADSTXT_SETTINGS_TAB:
     248                    self::render_adstxt_manager_settings_tab();
     249                    break;
     250                default:
     251                    self::render_video_insert_settings_tab();
     252                    break;
     253            }
     254            ?>
     255        </div>
     256    <?php
     257    }
     258
     259    public static function render_video_insert_settings_tab()
     260    {
    228261        ?>
    229262        <div class="wrap">
     
    231264            <p class="notice notice-info" style="padding: 15px;">
    232265                Automatically insert videos on all pages in this site.
    233                 <br/>
    234                 To configure the behavior and placement of the auto-inserted videos, visit the <a href="https://app.humix.com/site/settings/content-settings" target="_blank">Humix Dashboard</a>.
     266                <br />
     267                To configure the behavior and placement of the auto-inserted videos, visit the <a
     268                    href="https://app.humix.com/site/settings/content-settings" target="_blank">Humix Dashboard</a>.
    235269            </p>
    236270            <form action="options.php" method="post">
     
    252286            <h2>Channel Settings</h2>
    253287            <p class="notice notice-info" style="padding: 15px;">
    254                 Select a channel from your account below to display on this site at <a href="<?php echo $channel_page; ?>" target="_blank"><?php echo $channel_page; ?></a>
     288                Select a channel from your account below to display on this site at <a href="<?php echo $channel_page; ?>"
     289                    target="_blank"><?php echo $channel_page; ?></a>
    255290            </p>
    256291            <form action="options.php" method="post">
     
    274309                <br>
    275310                <br>
    276                 If you are setting up via the Humix dashboard, you can put in <code>70772</code> as the ID. If you created an account with <a href="https://www.adstxtmanager.com/" target="_blank">adstxtmanager.com</a>, click <a href="https://www.adstxtmanager.com/" target="_blank">here</a> to login and access your ID.
     311                If you are setting up via the Humix dashboard, you can put in <code>70772</code> as the ID. If you created an
     312                account with <a href="https://www.adstxtmanager.com/" target="_blank">adstxtmanager.com</a>, click <a
     313                    href="https://www.adstxtmanager.com/" target="_blank">here</a> to login and access your ID.
    277314            </p>
    278315            <form action="options.php" method="post">
     
    287324    }
    288325
    289     public static function render_insert_on_all_pages_option(){
    290         ?>
    291             <span style="position: absolute; left: 0; margin: 0 15px;">
    292             <input id="insert-on-all-pages" type="checkbox" name="<?php echo self::INSERT_ON_ALL_PAGES_OPTION; ?>" <?php \checked(self::get_insert_on_all_pages(), true); ?>>
     326    public static function render_insert_on_all_pages_option()
     327    {
     328        ?>
     329        <span style="position: absolute; left: 0; margin: 0 15px;">
     330            <input id="insert-on-all-pages" type="checkbox" name="<?php echo self::INSERT_ON_ALL_PAGES_OPTION; ?>" <?php \checked(self::get_insert_on_all_pages(), true); ?>>
    293331            <label for="insert-on-all-pages">Automatically insert video on all pages</label>
    294             </span>
    295             <br/>
    296         <?php
     332        </span>
     333        <br />
     334        <?php
    297335    }
    298336
    299337    public static function render_assigned_channel_id_option()
    300     {
    301         $auth = new \HumixNamespace\Authentication();
    302         $token = $auth->get_token_from_publisher_backend();
    303         $channels = [];
     338    {
     339        $auth = new \HumixNamespace\Authentication();
     340        $token = $auth->get_token_from_publisher_backend();
     341        $channels = [];
    304342        $load_channels_err = false;
    305         try {
    306             $channels = (new \HumixNamespace\Channels())->get_channels($token);
    307         } catch (\Exception $e) {
    308             \error_log("Humix Plugin Error: Failed to load channels: " . $e->getMessage());
    309             $load_channels_err = true;
    310         }
     343        try {
     344            $channels = (new \HumixNamespace\Channels())->get_channels($token);
     345        } catch (\Exception $e) {
     346            \error_log("Humix Plugin Error: Failed to load channels: " . $e->getMessage());
     347            $load_channels_err = true;
     348        }
    311349
    312350        if ($load_channels_err || empty($channels)) {
    313351            ?>
    314             <div id="setting-error-api_error" class="notice notice-error settings-error">
    315                 <p><strong>Failed to load your channels from your account. Please refresh the page and try again.</strong></p>
    316             </div>
    317             <?php
    318             return;
    319         }
    320 
    321         $selected_channel_id = self::get_assigned_channel_id();
    322         ?>
    323         <select name="<?php echo self::ASSIGNED_CHANNEL_ID_OPTION; ?>">
    324             <option value="-1" <?php \selected($selected_channel_id, -1); ?>>
    325                 <?php
    326                 echo (int) $selected_channel_id === -1 ? "Select a channel" : "Remove channel from this site";
    327                 ?>
    328             </option>
    329             <?php foreach ($channels as $channel): ?>
    330                 <option value="<?php echo \esc_attr($channel['humixChannelId']); ?>" <?php \selected($selected_channel_id, $channel['humixChannelId']); ?>>
    331                     <?php echo \esc_html($channel['name']); ?>
    332                 </option>
    333             <?php endforeach; ?>
    334         </select>
    335         <?php
    336     }
     352            <div id="setting-error-api_error" class="notice notice-error settings-error">
     353                <p><strong>Failed to load your channels from your account. Please refresh the page and try again.</strong></p>
     354            </div>
     355            <?php
     356            return;
     357        }
     358
     359        $selected_channel_id = self::get_assigned_channel_id();
     360        ?>
     361        <select name="<?php echo self::ASSIGNED_CHANNEL_ID_OPTION; ?>">
     362            <option value="-1" <?php \selected($selected_channel_id, -1); ?>>
     363                <?php
     364                echo (int) $selected_channel_id === -1 ? "Select a channel" : "Remove channel from this site";
     365                ?>
     366            </option>
     367            <?php foreach ($channels as $channel): ?>
     368                <option value="<?php echo \esc_attr($channel['humixChannelId']); ?>" <?php \selected($selected_channel_id, $channel['humixChannelId']); ?>>
     369                    <?php echo \esc_html($channel['name']); ?>
     370                </option>
     371            <?php endforeach; ?>
     372        </select>
     373        <?php
     374    }
    337375
    338376    public static function render_adstxt_manager_id_option()
    339377    {
    340378        $selected_option = self::get_adstxt_manager_id()
    341         ?>
    342         <input name="<?php echo self::ADSTXT_MANAGER_ID_OPTION; ?>" class="regular-text code" placeholder="Enter your Ads.txt Manager ID..."
    343             <?php
    344                 if($selected_option > 0) {
    345                     echo 'value="' . $selected_option . '"';
    346                 }
    347379            ?>
    348         ></input>
     380        <input name="<?php echo self::ADSTXT_MANAGER_ID_OPTION; ?>" class="regular-text code"
     381            placeholder="Enter your Ads.txt Manager ID..." <?php
     382            if ($selected_option > 0) {
     383                echo 'value="' . $selected_option . '"';
     384            }
     385            ?>></input>
    349386        <?php
    350387    }
     
    388425
    389426        // Allow user to pass empty string (or 0) to effectively clear out the value
    390         if($new_adstxt_manager_id === "") {
     427        if ($new_adstxt_manager_id === "") {
    391428            $new_adstxt_manager_id = 0;
    392429        }
  • humix/trunk/README.txt

    r3144450 r3173030  
    44Tags: humix, video, embed, network
    55Requires at least: 5.8.0
    6 Tested up to: 6.5
     6Tested up to: 6.6
    77Requires PHP: 7.0
    8 Stable tag: 1.4.1
     8Stable tag: 1.5.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2323
    2424== Changelog ==
     25= 1.5.0 =
     26* Improvements to channel hosting setup process
     27
    2528= 1.4.1 =
    2629* Changed adstxtmanager ID
  • humix/trunk/humix.php

    r3144450 r3173030  
    55require "HumixNamespace/Channels.php";
    66require "HumixNamespace/Settings.php";
     7require "HumixNamespace/RestApi.php";
    78
    89/**
     
    1516 *
    1617 * @link              https://www.humix.com/
    17  * @since             1.4.1
     18 * @since             1.5.0
    1819 * @package           Humix
    1920 *
     
    2223 * Plugin URI:        https://wordpress.org/plugins/humix
    2324 * Description:       Humix allows you to easily embed videos to your site from the Humix Network.
    24  * Version:           1.4.1
     25 * Version:           1.5.0
    2526 * Author:            Humix
    2627 * Author URI:        https://www.humix.com/
     
    3940 * Rename this for your plugin and update it as you release new versions.
    4041 */
    41 define('HUMIX_VERSION', '1.4.1');
     42define('HUMIX_VERSION', '1.5.0');
    4243
    4344global $EZHX_REGEX;
     
    6263    \HumixNamespace\Authentication::register();
    6364
     65    // register API endpoitns
     66    \HumixNamespace\RestApi::register();
     67
    6468    // handle rewrite rules for middleton requests appropriately
    6569    $assigned_humix_channel_id = \HumixNamespace\Settings::get_assigned_channel_id();
     
    7680    }
    7781
     82    // handle insert videos on all pages if enabled
    7883    $insert_on_all_pages = \HumixNamespace\Settings::get_insert_on_all_pages();
    7984    if ($insert_on_all_pages) {
Note: See TracChangeset for help on using the changeset viewer.