Skip to content

Commit 1c78a0c

Browse files
committed
added support for google plus #124
1 parent 45c6d29 commit 1c78a0c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Adapters/Google.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static function check(Request $request)
2020
'https://maps.google.*',
2121
'https://www.google.*/maps*',
2222
'https://drive.google.com/file/*/view',
23+
'https://plus.google.com/*/posts/*',
2324
]);
2425
}
2526

@@ -43,6 +44,11 @@ public function getCode()
4344
$this->width = null;
4445
$this->height = null;
4546

47+
if ($this->request->getHost() === 'plus.google.com') {
48+
return '<script src="https://apis.google.com/js/plusone.js" type="text/javascript"></script>'
49+
.'<div class="g-post" data-href="'.$this->request->getUrl().'"></div>';
50+
}
51+
4652
if (($google = $this->getProvider('google'))) {
4753
return $google->getCode();
4854
}
@@ -61,4 +67,16 @@ public function getImagesUrls()
6167
{
6268
return [];
6369
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public function getProviderName()
75+
{
76+
if ($this->request->getHost() === 'plus.google.com') {
77+
return 'Google Plus';
78+
}
79+
80+
return parent::getProviderName();
81+
}
6482
}

tests/GoogleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,17 @@ public function testDrive()
2626
]
2727
);
2828
}
29+
30+
public function testPlus()
31+
{
32+
$this->assertEmbed(
33+
'https://plus.google.com/u/0/+StephanHovnanian/posts/6apV9FHgo4k',
34+
[
35+
'title' => 'Grow your business through email marketing Learn more…',
36+
'type' => 'rich',
37+
'code' => '<script src="https://apis.google.com/js/plusone.js" type="text/javascript"></script><div class="g-post" data-href="https://plus.google.com/+StephanHovnanian/posts/6apV9FHgo4k"></div>',
38+
'providerName' => 'Google Plus',
39+
]
40+
);
41+
}
2942
}

0 commit comments

Comments
 (0)