From 238aece3968917ece7b995c61aa3e61d7dbb4ec1 Mon Sep 17 00:00:00 2001 From: Jen Lampton Date: Sun, 24 Dec 2017 11:21:22 -0800 Subject: [PATCH] Prevent PHP notices, and begin to port other metatag submodules. --- metatag_dc/metatag_dc.metatag.inc | 94 ++++++++------- .../metatag_dc_advanced.metatag.inc | 14 ++- metatag_favicons/metatag_favicons.metatag.inc | 2 +- .../metatag_google_plus.metatag.inc | 86 +++++++------- metatag_hreflang/metatag_hreflang.metatag.inc | 32 ++--- metatag_opengraph/metatag_opengraph.module | 112 +++++++++--------- .../metatag_twitter_cards.module | 88 +++++++------- 7 files changed, 220 insertions(+), 208 deletions(-) diff --git a/metatag_dc/metatag_dc.metatag.inc b/metatag_dc/metatag_dc.metatag.inc index 6f0ed30..26acbe9 100644 --- a/metatag_dc/metatag_dc.metatag.inc +++ b/metatag_dc/metatag_dc.metatag.inc @@ -9,57 +9,59 @@ */ function metatag_dc_metatag_bundled_config_alter(array &$configs) { foreach ($configs as &$config) { - switch ($config->instance) { - case 'global': - $config->config += array( - 'dcterms.format' => array('value' => 'text/html'), - 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), - 'dcterms.title' => array('value' => '[current-page:title]'), - 'dcterms.type' => array('value' => 'Text'), - ); - break; + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'global': + $config['config'] += array( + 'dcterms.format' => array('value' => 'text/html'), + 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), + 'dcterms.title' => array('value' => '[current-page:title]'), + 'dcterms.type' => array('value' => 'Text'), + ); + break; - case 'global:frontpage': - $config->config += array( - 'dcterms.description' => array('value' => '[site:slogan]'), - 'dcterms.identifier' => array('value' => '[site:url]'), - 'dcterms.title' => array('value' => '[site:name]'), - ); - break; + case 'global:frontpage': + $config['config'] += array( + 'dcterms.description' => array('value' => '[site:slogan]'), + 'dcterms.identifier' => array('value' => '[site:url]'), + 'dcterms.title' => array('value' => '[site:name]'), + ); + break; - // On error pages point everything to the homepage. - case 'global:403': - case 'global:404': - $config->config += array( - 'dcterms.identifier' => array('value' => '[site:url]'), - 'dcterms.title' => array('value' => '[site:name]'), - ); - break; + // On error pages point everything to the homepage. + case 'global:403': + case 'global:404': + $config['config'] += array( + 'dcterms.identifier' => array('value' => '[site:url]'), + 'dcterms.title' => array('value' => '[site:name]'), + ); + break; - case 'node': - $config->config += array( - 'dcterms.creator' => array('value' => '[node:author]'), - 'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'), - 'dcterms.description' => array('value' => '[node:summary]'), - 'dcterms.language' => array('value' => '[node:language]'), - 'dcterms.title' => array('value' => '[node:title]'), - ); - break; + case 'node': + $config['config'] += array( + 'dcterms.creator' => array('value' => '[node:author]'), + 'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'), + 'dcterms.description' => array('value' => '[node:summary]'), + 'dcterms.language' => array('value' => '[node:language]'), + 'dcterms.title' => array('value' => '[node:title]'), + ); + break; - case 'taxonomy_term': - $config->config += array( - 'dcterms.description' => array('value' => '[term:description]'), - 'dcterms.title' => array('value' => '[term:name]'), - ); - break; + case 'taxonomy_term': + $config['config'] += array( + 'dcterms.description' => array('value' => '[term:description]'), + 'dcterms.title' => array('value' => '[term:name]'), + ); + break; - case 'user': - $config->config += array( - 'dcterms.creator' => array('value' => '[user:name]'), - 'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'), - 'dcterms.title' => array('value' => '[user:name]'), - ); - break; + case 'user': + $config['config'] += array( + 'dcterms.creator' => array('value' => '[user:name]'), + 'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'), + 'dcterms.title' => array('value' => '[user:name]'), + ); + break; + } } } } diff --git a/metatag_dc_advanced/metatag_dc_advanced.metatag.inc b/metatag_dc_advanced/metatag_dc_advanced.metatag.inc index c4fc6ac..bf31788 100644 --- a/metatag_dc_advanced/metatag_dc_advanced.metatag.inc +++ b/metatag_dc_advanced/metatag_dc_advanced.metatag.inc @@ -9,12 +9,14 @@ */ function metatag_dc_advanced_metatag_bundled_config_alter(array &$configs) { foreach ($configs as &$config) { - switch ($config->instance) { - case 'node': - $config->config += array( - 'dcterms.modified' => array('value' => '[node:changed:custom:Y-m-d\TH:iP]'), - ); - break; + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'node': + $config['config'] += array( + 'dcterms.modified' => array('value' => '[node:changed:custom:Y-m-d\TH:iP]'), + ); + break; + } } } } diff --git a/metatag_favicons/metatag_favicons.metatag.inc b/metatag_favicons/metatag_favicons.metatag.inc index 9b4efe0..a661a0d 100644 --- a/metatag_favicons/metatag_favicons.metatag.inc +++ b/metatag_favicons/metatag_favicons.metatag.inc @@ -10,7 +10,7 @@ function metatag_favicons_metatag_bundled_config_alter(&$config) { $favicon = metatag_favicons_get_theme_favicon(); if (!empty($favicon)) { - $config['global']->config['shortcut icon'] = array('value' => $favicon); + $config['global']['config']['shortcut icon'] = array('value' => $favicon); } } diff --git a/metatag_google_plus/metatag_google_plus.metatag.inc b/metatag_google_plus/metatag_google_plus.metatag.inc index 9c57a60..bdede7a 100644 --- a/metatag_google_plus/metatag_google_plus.metatag.inc +++ b/metatag_google_plus/metatag_google_plus.metatag.inc @@ -9,54 +9,56 @@ */ function metatag_google_plus_metatag_bundled_config_alter(array &$configs) { foreach ($configs as &$config) { - switch ($config->instance) { - case 'global': - $config->config += array( - 'itemprop:name' => array('value' => '[current-page:title]'), - ); - break; + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'global': + $config['config'] += array( + 'itemprop:name' => array('value' => '[current-page:title]'), + ); + break; - case 'global:frontpage': - $config->config += array( - 'itemprop:name' => array('value' => '[site:name]'), - 'itemprop:description' => array('value' => '[site:slogan]'), - ); - break; + case 'global:frontpage': + $config['config'] += array( + 'itemprop:name' => array('value' => '[site:name]'), + 'itemprop:description' => array('value' => '[site:slogan]'), + ); + break; - // On error pages point everything to the homepage. - case 'global:403': - case 'global:404': - $config->config += array( - 'itemprop:name' => array('value' => '[site:name]'), - ); - break; + // On error pages point everything to the homepage. + case 'global:403': + case 'global:404': + $config['config'] += array( + 'itemprop:name' => array('value' => '[site:name]'), + ); + break; - case 'node': - $config->config += array( - 'itemprop:description' => array('value' => '[node:summary]'), - 'itemprop:name' => array('value' => '[node:title]'), - 'itemtype' => array('value' => 'Article'), - ); - break; + case 'node': + $config['config'] += array( + 'itemprop:description' => array('value' => '[node:summary]'), + 'itemprop:name' => array('value' => '[node:title]'), + 'itemtype' => array('value' => 'Article'), + ); + break; - case 'taxonomy_term': - $config->config += array( - 'itemprop:description' => array('value' => '[term:description]'), - 'itemprop:name' => array('value' => '[term:name]'), - ); - break; + case 'taxonomy_term': + $config['config'] += array( + 'itemprop:description' => array('value' => '[term:description]'), + 'itemprop:name' => array('value' => '[term:name]'), + ); + break; - case 'user': - $config->config += array( - 'itemprop:name' => array('value' => '[user:name]'), - 'itemtype' => array('value' => 'Person'), - ); - if (variable_get('user_pictures')) { - $config->config += array( - 'itemprop:image' => array('value' => '[user:picture:url]'), + case 'user': + $config['config'] += array( + 'itemprop:name' => array('value' => '[user:name]'), + 'itemtype' => array('value' => 'Person'), ); - } - break; + if (variable_get('user_pictures')) { + $config['config'] += array( + 'itemprop:image' => array('value' => '[user:picture:url]'), + ); + } + break; + } } } } diff --git a/metatag_hreflang/metatag_hreflang.metatag.inc b/metatag_hreflang/metatag_hreflang.metatag.inc index 8b8c1a6..90734ab 100644 --- a/metatag_hreflang/metatag_hreflang.metatag.inc +++ b/metatag_hreflang/metatag_hreflang.metatag.inc @@ -17,23 +17,25 @@ function metatag_hreflang_metatag_bundled_config_alter(array &$configs) { } foreach ($configs as &$config) { - switch ($config->instance) { - case 'node': - // The x-default should default to the source language. - $config->config += array( - 'hreflang_xdefault' => array('value' => '[node:source:url]'), - ); + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'node': + // The x-default should default to the source language. + $config['config'] += array( + 'hreflang_xdefault' => array('value' => '[node:source:url]'), + ); - // Add all of the other hreflang values. - $languages = language_list('enabled'); - if (!empty($languages[1])) { - foreach (array_keys($languages[1]) as $langcode) { - $config->config += array( - 'hreflang_' . $langcode => array('value' => '[node:url-' . $langcode . ']'), - ); + // Add all of the other hreflang values. + $languages = language_list('enabled'); + if (!empty($languages[1])) { + foreach (array_keys($languages[1]) as $langcode) { + $config['config'] += array( + 'hreflang_' . $langcode => array('value' => '[node:url-' . $langcode . ']'), + ); + } } - } - break; + break; + } } } } diff --git a/metatag_opengraph/metatag_opengraph.module b/metatag_opengraph/metatag_opengraph.module index 9fa2783..a6fa15f 100644 --- a/metatag_opengraph/metatag_opengraph.module +++ b/metatag_opengraph/metatag_opengraph.module @@ -9,68 +9,70 @@ */ function metatag_opengraph_metatag_bundled_config_alter(array &$configs) { foreach ($configs as &$config) { - switch ($config['instance']) { - case 'global': - $config['config'] += array( - 'og:site_name' => array('value' => '[site:name]'), - 'og:title' => array('value' => '[current-page:title]'), - 'og:type' => array('value' => 'article'), - 'og:url' => array('value' => '[current-page:url:absolute]'), - ); - break; + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'global': + $config['config'] += array( + 'og:site_name' => array('value' => '[site:name]'), + 'og:title' => array('value' => '[current-page:title]'), + 'og:type' => array('value' => 'article'), + 'og:url' => array('value' => '[current-page:url:absolute]'), + ); + break; - case 'global:frontpage': - $config['config'] += array( - 'og:description' => array('value' => '[site:slogan]'), - 'og:title' => array('value' => '[site:name]'), - 'og:type' => array('value' => 'website'), - 'og:url' => array('value' => '[site:url]'), - ); - break; + case 'global:frontpage': + $config['config'] += array( + 'og:description' => array('value' => '[site:slogan]'), + 'og:title' => array('value' => '[site:name]'), + 'og:type' => array('value' => 'website'), + 'og:url' => array('value' => '[site:url]'), + ); + break; - // On error pages point everything to the homepage. - case 'global:403': - case 'global:404': - $config['config'] += array( - 'og:title' => array('value' => '[site:name]'), - 'og:type' => array('value' => 'website'), - 'og:url' => array('value' => '[site:url]'), - ); - break; + // On error pages point everything to the homepage. + case 'global:403': + case 'global:404': + $config['config'] += array( + 'og:title' => array('value' => '[site:name]'), + 'og:type' => array('value' => 'website'), + 'og:url' => array('value' => '[site:url]'), + ); + break; - case 'node': - $config['config'] += array( - 'article:modified_time' => array('value' => '[node:changed:custom:c]'), - 'article:published_time' => array('value' => '[node:created:custom:c]'), - 'og:description' => array('value' => '[node:summary]'), - 'og:title' => array('value' => '[node:title]'), - 'og:updated_time' => array('value' => '[node:changed:custom:c]'), - 'og:image' => array('value' => '[node:field_image]'), - 'og:image:url' => array('value' => '[node:field_image]'), - ); - break; + case 'node': + $config['config'] += array( + 'article:modified_time' => array('value' => '[node:changed:custom:c]'), + 'article:published_time' => array('value' => '[node:created:custom:c]'), + 'og:description' => array('value' => '[node:summary]'), + 'og:title' => array('value' => '[node:title]'), + 'og:updated_time' => array('value' => '[node:changed:custom:c]'), + 'og:image' => array('value' => '[node:field_image]'), + 'og:image:url' => array('value' => '[node:field_image]'), + ); + break; - case 'taxonomy_term': - $config['config'] += array( - 'og:description' => array('value' => '[term:description]'), - 'og:title' => array('value' => '[term:name]'), - ); - break; + case 'taxonomy_term': + $config['config'] += array( + 'og:description' => array('value' => '[term:description]'), + 'og:title' => array('value' => '[term:name]'), + ); + break; - case 'user': - $config['config'] += array( - 'og:title' => array('value' => '[user:name]'), - 'og:type' => array('value' => 'profile'), - 'profile:username' => array('value' => '[user:name]'), - ); - if (config_get('system.core', 'user_pictures')) { + case 'user': $config['config'] += array( - 'og:image' => array('value' => '[user:picture:url]'), - // For now keep the old default. - // 'og:image:url' => array('value' => '[user:picture:url]'), + 'og:title' => array('value' => '[user:name]'), + 'og:type' => array('value' => 'profile'), + 'profile:username' => array('value' => '[user:name]'), ); - } - break; + if (config_get('system.core', 'user_pictures')) { + $config['config'] += array( + 'og:image' => array('value' => '[user:picture:url]'), + // For now keep the old default. + // 'og:image:url' => array('value' => '[user:picture:url]'), + ); + } + break; + } } } } diff --git a/metatag_twitter_cards/metatag_twitter_cards.module b/metatag_twitter_cards/metatag_twitter_cards.module index a672c67..157f3c1 100644 --- a/metatag_twitter_cards/metatag_twitter_cards.module +++ b/metatag_twitter_cards/metatag_twitter_cards.module @@ -9,56 +9,58 @@ */ function metatag_twitter_cards_metatag_bundled_config_alter(array &$configs) { foreach ($configs as &$config) { - switch ($config['instance']) { - case 'global': - $config['config'] += array( - 'twitter:card' => array('value' => 'summary'), - 'twitter:title' => array('value' => '[current-page:title]'), - 'twitter:url' => array('value' => '[current-page:url:absolute]'), - ); - break; + if (isset($config['instance'])) { + switch ($config['instance']) { + case 'global': + $config['config'] += array( + 'twitter:card' => array('value' => 'summary'), + 'twitter:title' => array('value' => '[current-page:title]'), + 'twitter:url' => array('value' => '[current-page:url:absolute]'), + ); + break; - case 'global:frontpage': - $config['config'] += array( - 'twitter:description' => array('value' => '[site:slogan]'), - 'twitter:title' => array('value' => '[site:name]'), - 'twitter:url' => array('value' => '[site:url]'), - ); - break; + case 'global:frontpage': + $config['config'] += array( + 'twitter:description' => array('value' => '[site:slogan]'), + 'twitter:title' => array('value' => '[site:name]'), + 'twitter:url' => array('value' => '[site:url]'), + ); + break; - // On error pages point everything to the homepage. - case 'global:403': - case 'global:404': - $config['config'] += array( - 'twitter:title' => array('value' => '[site:name]'), - 'twitter:url' => array('value' => '[site:url]'), - ); - break; + // On error pages point everything to the homepage. + case 'global:403': + case 'global:404': + $config['config'] += array( + 'twitter:title' => array('value' => '[site:name]'), + 'twitter:url' => array('value' => '[site:url]'), + ); + break; - case 'node': - $config['config'] += array( - 'twitter:description' => array('value' => '[node:summary]'), - 'twitter:title' => array('value' => '[node:title]'), - ); - break; + case 'node': + $config['config'] += array( + 'twitter:description' => array('value' => '[node:summary]'), + 'twitter:title' => array('value' => '[node:title]'), + ); + break; - case 'taxonomy_term': - $config['config'] += array( - 'twitter:description' => array('value' => '[term:description]'), - 'twitter:title' => array('value' => '[term:name]'), - ); - break; + case 'taxonomy_term': + $config['config'] += array( + 'twitter:description' => array('value' => '[term:description]'), + 'twitter:title' => array('value' => '[term:name]'), + ); + break; - case 'user': - $config['config'] += array( - 'twitter:title' => array('value' => '[user:name]'), - ); - if (config_get('system.core', 'user_pictures')) { + case 'user': $config['config'] += array( - 'twitter:image' => array('value' => '[user:picture:url]'), + 'twitter:title' => array('value' => '[user:name]'), ); - } - break; + if (config_get('system.core', 'user_pictures')) { + $config['config'] += array( + 'twitter:image' => array('value' => '[user:picture:url]'), + ); + } + break; + } } } }