Skip to content

Commit f18ca55

Browse files
authored
Merge pull request #34 from nguyenanhung/v3.2.0-develop
V3.2.0 develop
2 parents 9f9aaf4 + 4b69005 commit f18ca55

File tree

3 files changed

+46
-23
lines changed

3 files changed

+46
-23
lines changed

helpers/common.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,17 @@ function codeigniter_hmvc_module_exists($module_name)
3030
*/
3131
function codeigniter_hmvc_modules_list($with_location = true)
3232
{
33-
if (!function_exists('directory_map'))
34-
{
33+
if (!function_exists('directory_map')) {
3534
get_instance()->load->helper('directory');
3635
}
3736

3837
$modules = array();
3938

40-
foreach (Modules::$locations as $location => $offset)
41-
{
39+
foreach (Modules::$locations as $location => $offset) {
4240
$files = directory_map($location, 1);
43-
if (is_array($files))
44-
{
45-
foreach ($files as $name)
46-
{
47-
if (is_dir($location . $name))
48-
{
41+
if (is_array($files)) {
42+
foreach ($files as $name) {
43+
if (is_dir($location . $name)) {
4944
$modules[] = $with_location ? array($location, $name) : $name;
5045
}
5146
}

system/helpers/seo_helper.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
3+
if (!function_exists('bear_simple_seo_header')) {
4+
/**
5+
* Function bear_simple_seo_header
6+
*
7+
* @param $title
8+
* @param $description
9+
* @param $image
10+
*
11+
* @author : 713uk13m <dev@nguyenanhung.com>
12+
* @copyright: 713uk13m <dev@nguyenanhung.com>
13+
* @time : 23/04/2023 23:49
14+
*/
15+
function bear_simple_seo_header($title = '', $description = '', $image = '')
16+
{
17+
$CI =& get_instance();
18+
$cms = $CI->load->library('seo_onpage');
19+
/** @var \CI_Seo_onpage $seo */
20+
$seo = $cms->seo_onpage;
21+
$seo->published($title, $description, $image);
22+
}
23+
}

system/libraries/Seo_onpage.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
* @copyright 713uk13m <dev@nguyenanhung.com>
1717
*
1818
* $config['canonical_url'] = null;
19-
$config['site_title'] = "Site Title";
20-
$config['site_description'] = "Site Description";
21-
$config['site_image'] = null;
22-
$config['twitter_user'] = "@tw_username";
23-
$config['fb_app_id'] = null;
24-
$config['fb_page_id'] = null;
19+
* $config['site_title'] = "Site Title";
20+
* $config['site_description'] = "Site Description";
21+
* $config['site_image'] = null;
22+
* $config['twitter_user'] = "@tw_username";
23+
* $config['fb_app_id'] = null;
24+
* $config['fb_page_id'] = null;
2525
*/
2626
class CI_Seo_onpage
2727
{
@@ -35,6 +35,11 @@ public function __construct()
3535
$this->CI->load->helper('url');
3636
}
3737

38+
public function published($title = "", $description = "", $image = "")
39+
{
40+
$this->set_tags($title, $description, $image);
41+
}
42+
3843
public function set_tags($title = "", $description = "", $image = "")
3944
{
4045
$current_url = current_url();
@@ -48,7 +53,7 @@ public function set_tags($title = "", $description = "", $image = "")
4853
$this->set_canonical();
4954
}
5055

51-
private function set_title_tags($title)
56+
protected function set_title_tags($title)
5257
{
5358
if ($title !== "") {
5459
echo "<title>$title</title>\n";
@@ -63,7 +68,7 @@ private function set_title_tags($title)
6368

6469
}
6570

66-
private function set_description_tags($description)
71+
protected function set_description_tags($description)
6772
{
6873
if ($description !== "") {
6974
echo "<meta name='description' content='$description'/>\n";
@@ -76,7 +81,7 @@ private function set_description_tags($description)
7681
}
7782
}
7883

79-
private function set_image_tags($image)
84+
protected function set_image_tags($image)
8085
{
8186
$image_path = null;
8287

@@ -96,14 +101,14 @@ private function set_image_tags($image)
96101
}
97102
}
98103

99-
private function set_twitter_tags()
104+
protected function set_twitter_tags()
100105
{
101106
if ($this->CI->config->item('twitter_user') !== "") {
102107
echo "<meta name='twitter:site' content='" . $this->CI->config->item('twitter_user') . "' />\n";
103108
}
104109
}
105110

106-
private function set_facebook_tags()
111+
protected function set_facebook_tags()
107112
{
108113
if ($this->CI->config->item('fb_page_id') !== "") {
109114
echo "<meta property='fb:pages' content='" . $this->CI->config->item('fb_page_id') . "' />\n";
@@ -114,14 +119,14 @@ private function set_facebook_tags()
114119
}
115120
}
116121

117-
private function set_canonical()
122+
protected function set_canonical()
118123
{
119124
if ($this->CI->config->item('canonical_url') !== "") {
120125
echo "<link rel='canonical' href='" . $this->CI->config->item('canonical_url') . "' />\n";
121126
}
122127
}
123128

124-
private function format_image_tags($image_path)
129+
protected function format_image_tags($image_path)
125130
{
126131
$path = parse_url($image_path);
127132

0 commit comments

Comments
 (0)