Skip to content

Commit

Permalink
Fix missing google/bing meta by merging default fields before augment…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
jesseleite committed Nov 25, 2020
1 parent b059813 commit 46d0e4e
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 222 deletions.
2 changes: 1 addition & 1 deletion src/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getConfig()
'allowed_fieldtypes' => [
'assets',
],
'field' => $this->getAssetFieldConfig(),
'field' => static::getAssetFieldConfig(),
],
],
[
Expand Down
2 changes: 1 addition & 1 deletion src/HasAssetField.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait HasAssetField
*
* @return array
*/
protected function getAssetFieldConfig()
protected static function getAssetFieldConfig()
{
if (! $container = config('statamic.seo-pro.assets.container')) {
return false;
Expand Down
220 changes: 2 additions & 218 deletions src/Http/Controllers/SiteDefaultsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
namespace Statamic\SeoPro\Http\Controllers;

use Illuminate\Http\Request;
use Statamic\Facades\Blueprint;
use Statamic\Http\Controllers\CP\CpController;
use Statamic\SeoPro\HasAssetField;
use Statamic\SeoPro\SiteDefaults;
use Statamic\Support\Arr;

class SiteDefaultsController extends CpController
{
use HasAssetField;

public function edit()
{
$blueprint = $this->blueprint();
$blueprint = SiteDefaults::blueprint();

$fields = $blueprint
->fields()
Expand All @@ -33,7 +29,7 @@ public function edit()

public function update(Request $request)
{
$blueprint = $this->blueprint();
$blueprint = SiteDefaults::blueprint();

$fields = $blueprint->fields()->addValues($request->all());

Expand All @@ -43,216 +39,4 @@ public function update(Request $request)

SiteDefaults::load($values)->save();
}

protected function blueprint()
{
return Blueprint::make()->setContents([
'sections' => [
'meta' => [
'display' => __('Meta'),
'fields' => [
[
'handle' => 'meta_section',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.meta_section'),
'instructions' => __('seo-pro::fieldsets/defaults.meta_section_instruct'),
'type' => 'section',
],
],
[
'handle' => 'title',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.title'),
'instructions' => __('seo-pro::fieldsets/defaults.title_instruct'),
'type' => 'seo_pro_source',
'inherit' => false,
'field' => [
'type' => 'text',
],
],
],
[
'handle' => 'description',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.description'),
'instructions' => __('seo-pro::fieldsets/defaults.description_instruct'),
'type' => 'seo_pro_source',
'inherit' => false,
'field' => [
'type' => 'textarea',
],
],
],
[
'handle' => 'site_name',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.site_name'),
'instructions' => __('seo-pro::fieldsets/defaults.site_name_instruct'),
'type' => 'text',
],
],
[
'handle' => 'site_name_position',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.site_name_position'),
'instructions' => __('seo-pro::fieldsets/defaults.site_name_position_instruct'),
'type' => 'select',
'options' => [
'after' => 'After',
'before' => 'Before',
'none' => 'Disable',
],
'width' => 50,
],
],
[
'handle' => 'site_name_separator',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.site_name_separator'),
'instructions' => __('seo-pro::fieldsets/defaults.site_name_separator_instruct'),
'type' => 'text',
'width' => 50,
],
],
[
'handle' => 'robots',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.robots'),
'instructions' => __('seo-pro::fieldsets/defaults.robots_instruct'),
'type' => 'select',
'multiple' => true,
'options' => [
'noindex',
'nofollow',
],
],
],
],
],
'image' => [
'display' => __('Image'),
'fields' => [
[
'handle' => 'image_section',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.image_section'),
'instructions' => __('seo-pro::fieldsets/defaults.image_section_instruct'),
'type' => 'section',
],
],
[
'handle' => 'image',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.image'),
'instructions' => __('seo-pro::fieldsets/defaults.image_instruct'),
'type' => 'seo_pro_source',
'inherit' => false,
'default' => false,
'disableable' => true,
'allowed_fieldtypes' => [
'assets',
],
'field' => $this->getAssetFieldConfig(),
],
],
],
],
'social' => [
'display' => __('Social'),
'fields' => [
[
'handle' => 'social_section',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.social_section'),
'instructions' => __('seo-pro::fieldsets/defaults.social_section_instruct'),
'type' => 'section',
],
],
[
'handle' => 'twitter_handle',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.twitter_handle'),
'instructions' => __('seo-pro::fieldsets/defaults.twitter_handle_instruct'),
'type' => 'text',
],
],
],
],
'sitemap' => [
'display' => __('Sitemap'),
'fields' => [
[
'handle' => 'sitemap_section',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.sitemap_section'),
'instructions' => __('seo-pro::fieldsets/defaults.sitemap_section_instruct'),
'type' => 'section',
],
],
[
'handle' => 'priority',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.priority'),
'instructions' => __('seo-pro::fieldsets/defaults.priority_instruct'),
'type' => 'seo_pro_source',
'inherit' => false,
'field' => [
'type' => 'text',
],
],
],
[
'handle' => 'change_frequency',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.change_frequency'),
'instructions' => __('seo-pro::fieldsets/defaults.change_frequency_instruct'),
'type' => 'seo_pro_source',
'inherit' => false,
'field' => [
'type' => 'select',
'options' => [
'hourly' => 'Hourly',
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthly' => 'Monthly',
'yearly' => 'Yearly',
'never' => 'Never',
],
],
],
],
],
],
'search' => [
'display' => __('Search Engines'),
'fields' => [
[
'handle' => 'search_section',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.search_section'),
'instructions' => __('seo-pro::fieldsets/defaults.search_section_instruct'),
'type' => 'section',
],
],
[
'handle' => 'bing_verification',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.bing_verification'),
'instructions' => __('seo-pro::fieldsets/defaults.bing_verification_instruct'),
'type' => 'text',
],
],
[
'handle' => 'google_verification',
'field' => [
'display' => __('seo-pro::fieldsets/defaults.google_verification'),
'instructions' => __('seo-pro::fieldsets/defaults.google_verification_instruct'),
'type' => 'text',
],
],
],
],
],
]);
}
}

0 comments on commit 46d0e4e

Please sign in to comment.