PHP code example of wanze / seo-maestro

1. Go to this page and download the library: Download wanze/seo-maestro library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wanze / seo-maestro example snippets


// Render all meta tags, including the common ones.
echo $page->seo;
// or...
echo $page->seo->render();

// Render groups individually, e.g. the opengraph meta data.
echo $page->seo->opengraph->render();

// Get a single value.
echo $page->seo->meta->description;

$page->of(false);

// Set values as strings or placeholders to reference the value of another field.
$page->seo->opengraph->description = 'A description for opengraph';
$page->seo->meta->title = '{title}';

// Inherit the Twitter card value from the field configuration.
$page->seo->twitter->card = 'inherit';

// Include the page in the sitemap and bump its priority.
$page->seo->sitemap->

$current = $user->language;

$user->language = $languages->get('de');

$page->of(false);
$page->seo->opengraph->title = 'Hallo Welt';
$page->save();

$user->language = $current;

// Remove the description and canonical URL.
$wire->addHookAfter('SeoMaestro::renderMetatags', function (HookEvent $event) {
    $tags = $event->arguments(0);
    $group = $event->arguments(1);

    if ($group === 'meta') {
        unset($tags['description']);
        unset($tags['canonicalUrl']);
        $event->return = $tags;
    }
});

// Add the brand name after the title. 
$wire->addHookAfter('SeoMaestro::renderSeoDataValue', function (HookEvent $event) {
    $group = $event->arguments(0);
    $name = $event->arguments(1);
    $value = $event->arguments(2);
    
    if ($group === 'meta' && $name === 'title') {
        $event->return = $value . ' | acme.com';
    }
});

$wire->addHookAfter('SeoMaestro::sitemapAlwaysExclude', function (HookEvent $event) {
    $pageArray = $event->arguments(0);
    $pageArray->add($excludedPage);
});

$item = (new SitemapItem())
    ->set('loc', '/en/my-custom-url')
    ->set('priority', 'custom-priority')
    ->set('changefreq', 'changefreq-custom')
    ->addAlternate('de', '/de/my-custom-url-de');

$wire->addHookAfter('SeoMaestro::sitemapItems', function (HookEvent $event) use ($item) {
    $event->return = array_merge($event->return, [$item]);
});

$pages->find('seo.sitemap_

cd site/modules/SeoMaestro && vendor/bin/phpunit --bootstrap tests/bootstrap.php tests/src --colors