コード例 #1
0
ファイル: lib-plugins.php プロジェクト: milk54/geeklog-japan
/**
* This function is called from COM_siteHeader and other places where meta tags
* are being built and will return additional meta tags.
*
* @param    string   $type     item type of the caller, e.g. 'article', 'staticpages'
* @param    string   $id       id of the current item of the caller
* @param    string   $myTags   meta tags the caller wants to add (optional)
* @return   string             all meta tags
* @since    Geeklog 2.1.0
*
*/
function PLG_getMetaTags($type, $id, array $myTags = array())
{
    global $_CONF, $_PLUGINS;
    $type = strtolower(trim($type));
    $id = trim($id);
    require_once $_CONF['path_system'] . 'classes/metatags.class.php';
    $charset = COM_getCharset();
    $htmlVersion = $_CONF['doctype'] === 'xhtml5' ? 5 : 4;
    $isXhtml = stripos($_CONF['doctype'], 'xhtml') === 0;
    $obj = new Metatags($charset, $htmlVersion, $isXhtml);
    //  $obj->setLog($_CONF['path'] . 'logs/error.log');
    // First, adds meta tags plugins want to add (the lowest priority)
    foreach ($_PLUGINS as $pi_name) {
        $function = 'plugin_getmetatags_' . $pi_name;
        if ($type !== $pi_name && function_exists($function)) {
            $metatags = $function($type, $id);
            if (is_array($metatags) && count($metatags) > 0) {
                foreach ($metatags as $tag) {
                    $obj->addTag($tag);
                }
            }
        }
    }
    // Then, adds meta tags the custom function wants to add
    $function = 'CUSTOM_getmetatags';
    if (function_exists($function)) {
        $metatags = $function($type, $id);
        if (is_array($metatags) && count($metatags) > 0) {
            foreach ($metatags as $tag) {
                $obj->addTag($tag);
            }
        }
    }
    // Finally, adds meta tags the caller itself wants to add (the highest priority)
    if (count($myTags) > 0) {
        foreach ($myTags as $tag) {
            $obj->addTag($tag);
        }
    }
    return $obj->build();
}
コード例 #2
0
ファイル: metatags.php プロジェクト: davidliuliuliu/sublite
    case 'hubs':
        $title = "SubLite – Meet and Socialize with Students Working in Your City";
        Metatags::bothTitles($title);
        Metatags::ogImage("https://sublite.net/app/assets/gfx/socialmain.jpg");
        Metatags::ogDescription("Get your questions answered and make new friends this summer!");
        Metatags::ogImageWidth(1677);
        Metatags::ogImageHeight(1118);
        break;
    case 'searchhousing':
        $data = View::get('data');
        $location = '';
        if ($data && isset($data['location'])) {
            $location = " - {$data['location']}";
        }
        $title = "SubLite – Search for Sublets, Rentals, and Other Housing{$location}";
        Metatags::bothTitles($title);
        Metatags::defaultImages();
        Metatags::defaultDescription();
        break;
    case 'searchjobs':
        $title = "SubLite – Search for Jobs and Internships";
        Metatags::bothTitles($title);
        Metatags::defaultImages();
        Metatags::defaultDescription();
        break;
    default:
        $title = "SubLite – Your One-Stop Shop for a Great Summer!";
        Metatags::bothTitles($title);
        Metatags::defaultImages();
        Metatags::defaultDescription();
}