1
|
|
|
<?php
|
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
/**
|
5
|
|
|
* Shortcode: Announcement Slider
|
6
|
|
|
*/
|
7
|
|
|
function announcement_slider($atts, $content = null){
|
|
|
|
|
8
|
|
|
|
9
|
|
|
ob_start();
|
10
|
|
|
|
11
|
|
|
echo '<div class="messages"> <div id="announcement_slider" class="owl-carousel">';
|
12
|
|
|
|
13
|
|
|
if( have_rows('announcement', 'option') ):
|
|
|
|
|
14
|
|
|
while ( have_rows('announcement', 'option') ) : the_row();
|
|
|
|
|
15
|
|
|
$message = get_sub_field('messages');
|
16
|
|
|
$message_link = get_sub_field('link');
|
17
|
|
|
|
18
|
|
|
echo '<div class="col-xs-12">';
|
19
|
|
|
echo '<a href=" ' . $message_link .' " " title="Click to read full messages"> ' . $message .' </a>';
|
20
|
|
|
echo '</div>';
|
21
|
|
|
endwhile;
|
22
|
|
|
else :
|
23
|
|
|
echo '<div class="col-xs-12">No Messages to Show!</div>';
|
24
|
|
|
endif;
|
25
|
|
|
echo '</div></div>';
|
26
|
|
|
|
27
|
|
|
$output = ob_get_clean();
|
28
|
|
|
return $output;
|
29
|
|
|
}
|
30
|
|
|
|
31
|
|
|
add_shortcode('announcement','announcement_slider');
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/**
|
36
|
|
|
* Shortcode: Recent Post Slider
|
37
|
|
|
*/
|
38
|
|
|
function recent_post_slider($atts, $content = null){
|
|
|
|
|
39
|
|
|
|
40
|
|
|
ob_start();
|
41
|
|
|
|
42
|
|
|
echo '<div class="post-slider row"><div id="recent-posts" class="owl-carousel">';
|
43
|
|
|
|
44
|
|
|
global $post;
|
|
|
|
|
45
|
|
|
$post_query = new WP_Query( array(
|
46
|
|
|
'post_type' => 'post',
|
47
|
|
|
'posts_per_page' => 12,
|
48
|
|
|
'order'=>'DESC',
|
49
|
|
|
'orderby' => 'date',
|
50
|
|
|
)
|
51
|
|
|
);
|
52
|
|
|
|
53
|
|
|
if( $post_query->have_posts() ) : while( $post_query->have_posts() ) : $post_query->the_post();
|
54
|
|
|
$thumb_post = wp_get_attachment_image_src( get_post_thumbnail_id(), 'lighthouse_related_post');
|
55
|
|
|
$url_post = $thumb_post[0];
|
56
|
|
|
$content = get_the_content();
|
57
|
|
|
|
58
|
|
|
echo '<div class="col-xs-12"><div class="thumbnail thumbnail-hover">';
|
59
|
|
|
echo '<img class="img-responsive" src=" ' . $url_post . '">';
|
60
|
|
|
echo '<a href=" ' . get_permalink() .' " " title=" ' . get_the_title() .' " class="overlay"></a>';
|
61
|
|
|
echo '</div>';
|
62
|
|
|
echo '<div class="entry">';
|
63
|
|
|
echo '<h3><a href=" ' . get_permalink() . ' "> ' . get_the_title() . '</a></h3>';
|
64
|
|
|
echo '<span class="date"> <i class="fa fa-clock-o"></i> ' . get_the_time(get_option('date_format')) .'</span>';
|
65
|
|
|
echo '<div class="entry-content">' . wp_trim_words( $content , '27' ) . '</div>';
|
66
|
|
|
echo '<div class="read-more">';
|
67
|
|
|
echo '<a href="' . get_permalink() . ' " class="btn read-more-btn">View Article</a>';
|
68
|
|
|
echo '</div>';
|
69
|
|
|
echo '</div></div>';
|
70
|
|
|
|
71
|
|
|
endwhile;
|
72
|
|
|
wp_reset_postdata();
|
73
|
|
|
endif;
|
74
|
|
|
|
75
|
|
|
echo '</div></div>';
|
76
|
|
|
|
77
|
|
|
$output = ob_get_clean();
|
78
|
|
|
return $output;
|
79
|
|
|
}
|
80
|
|
|
|
81
|
|
|
add_shortcode('recent_posts','recent_post_slider');
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/**
|
85
|
|
|
* Shortcode: Member logo slider
|
86
|
|
|
*/
|
87
|
|
|
function member_logo_slider($atts, $content = null){
|
|
|
|
|
88
|
|
|
|
89
|
|
|
ob_start();
|
90
|
|
|
|
91
|
|
|
echo '<div class="members-logo row"> <div id="logo-slider" class="owl-carousel">';
|
92
|
|
|
|
93
|
|
|
if( have_rows('members_logo', 'option') ):
|
|
|
|
|
94
|
|
|
while ( have_rows('members_logo', 'option') ) : the_row();
|
|
|
|
|
95
|
|
|
$logo_url = get_sub_field('logo');
|
96
|
|
|
$company_link = get_sub_field('link');
|
97
|
|
|
|
98
|
|
|
echo '<div class="thumbnail thumbnail-hover">';
|
99
|
|
|
echo '<img class="img-responsive" src=" ' . $logo_url . '">';
|
100
|
|
|
echo '<a href=" ' . $company_link .' " " title=" ' . $company_link .' " class="link-full"></a>';
|
101
|
|
|
echo '</div>';
|
102
|
|
|
|
103
|
|
|
endwhile;
|
104
|
|
|
else :
|
105
|
|
|
echo '<div class="col-xs-12">Members Logo Slider not found! <be> please add some logo in theme setting page</div>';
|
106
|
|
|
endif;
|
107
|
|
|
echo '</div></div>';
|
108
|
|
|
|
109
|
|
|
$output = ob_get_clean();
|
110
|
|
|
return $output;
|
111
|
|
|
}
|
112
|
|
|
|
113
|
|
|
add_shortcode('members_logo','member_logo_slider');
|
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/**
|
117
|
|
|
* Shortcode: Share Price
|
118
|
|
|
*/
|
119
|
|
|
function share_price_feed($atts, $content = null){
|
|
|
|
|
120
|
|
|
|
121
|
|
|
ob_start();
|
122
|
|
|
|
123
|
|
|
$xmldat = file_get_contents('http://qfx.quartalflife.com/clients/uk/lighthouse_group/xml/xml.aspx');
|
124
|
|
|
file_put_contents('./wp-content/themes/lighthouse/xml-feeds/share-price.xml', $xmldat);
|
125
|
|
|
|
126
|
|
|
$url = './wp-content/themes/lighthouse/xml-feeds/share-price.xml';
|
127
|
|
|
$xml = simplexml_load_file($url);
|
128
|
|
|
$price = $xml->CurrentPrice;
|
|
|
|
|
129
|
|
|
$change = $xml->Change;
|
|
|
|
|
130
|
|
|
$change_pcent = $xml->PercentageChange;
|
|
|
|
|
131
|
|
|
$volume = $xml->Volume;
|
|
|
|
|
132
|
|
|
$Date = $xml->Date;
|
|
|
|
|
133
|
|
|
$time = $xml->time;
|
|
|
|
|
134
|
|
|
|
135
|
|
|
echo '<div class="share_price_feed">';
|
136
|
|
|
|
137
|
|
|
echo '<div class="feed_options"><div class="share_data_title">Share Price:</div><div class="share_data">' . $price . '</div></div>';
|
138
|
|
|
echo '<div class="feed_options"><div class="share_data_title">Change:</div><div class="share_data">' . $change . 'p</div></div>';
|
139
|
|
|
echo '<div class="feed_options"><div class="share_data_title">Volume:</div><div class="share_data">' . $volume . '</div></div>';
|
140
|
|
|
echo '<div class="feed_options"><div class="share_data_title">Date:</div><div class="share_data">' . $Date . '</div></div>';
|
141
|
|
|
echo '<div class="feed_options"><div class="share_data_title">Time:</div><div class="share_data">' . $time . '</div></div>';
|
142
|
|
|
|
143
|
|
|
echo '</div>';
|
144
|
|
|
|
145
|
|
|
$output = ob_get_clean();
|
146
|
|
|
return $output;
|
147
|
|
|
}
|
148
|
|
|
|
149
|
|
|
add_shortcode('share_price','share_price_feed');
|
150
|
|
|
|
151
|
|
|
|
152
|
|
|
|
153
|
|
|
/**
|
154
|
|
|
* Shortcode: RNS Feeds
|
155
|
|
|
*/
|
156
|
|
|
function rns_feed_fn($atts, $content = null){
|
|
|
|
|
157
|
|
|
|
158
|
|
|
ob_start();
|
159
|
|
|
|
160
|
|
|
$xmldata = file_get_contents('http://otp.investis.com/clients/uk/lighthouse_group_plc/rns/xml-feed.aspx?culture=en-GB');
|
161
|
|
|
file_put_contents('./wp-content/themes/lighthouse/xml-feeds/rns-feed.xml', $xmldata);
|
162
|
|
|
|
163
|
|
|
$url = './wp-content/themes/lighthouse/xml-feeds/rns-feed.xml';
|
164
|
|
|
$xml = simplexml_load_file($url);
|
165
|
|
|
|
166
|
|
|
foreach ($xml->RNSSummaries->RNSSummary as $RNSSummary) {
|
167
|
|
|
$RNSDateTime = $RNSSummary->pubDate;
|
168
|
|
|
$RNSDate = substr($RNSDateTime, 5, 11);
|
169
|
|
|
$RNSLink = $RNSSummary->ShareURL;
|
170
|
|
|
$RNSTitle = $RNSSummary->Title;
|
171
|
|
|
|
172
|
|
|
echo $RNSDate, ' – <a title="Read article" href=" ', $RNSLink, ' " target="_blank"> ', $RNSTitle, ' </a><br> ', PHP_EOL;
|
173
|
|
|
}
|
174
|
|
|
|
175
|
|
|
$output = ob_get_clean();
|
176
|
|
|
return $output;
|
177
|
|
|
}
|
178
|
|
|
|
179
|
|
|
add_shortcode('rns_feed','rns_feed_fn'); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.