Completed
Push — master ( e99530...bf2509 )
by Md. Mozahidur
03:33
created

includes/shortcodes.php (11 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php 
2
3
/**
4
 * Shortcode: Recent Post Slider
5
 */
6
function recent_post_slider($atts, $content = null){
7
8
	ob_start();
9
10
	echo '<div class="post-slider row"><div id="recent-posts" class="owl-carousel">';
11
12
	global $post;
13
	$post_query = new WP_Query( array(
14
		'post_type' => 'post',
15
		'posts_per_page' => 12,
16
		'order'=>'DESC',
17
		'orderby' => 'date',
18
		)
19
	);
20
21
	if( $post_query->have_posts() ) : while( $post_query->have_posts() ) : $post_query->the_post();
22
	$thumb_post = wp_get_attachment_image_src( get_post_thumbnail_id(), 'lighthouse_related_post');
23
	$url_post = $thumb_post[0];
24
	$content = get_the_content();
25
26
	echo '<div class="col-xs-12"><div class="thumbnail thumbnail-hover">';
27
	echo '<img class="img-responsive" src=" ' . $url_post . '">';
28
	echo '<a href=" ' . get_permalink() .' " " title=" ' .  get_the_title() .' " class="overlay"></a>';
29
	echo '</div>';
30
	echo '<div class="entry">';
31
	echo '<h3><a href=" ' . get_permalink() . ' "> ' . get_the_title() . '</a></h3>';
32
	echo '<span class="date"> <i class="fa fa-clock-o"></i> ' . get_the_time(get_option('date_format')) .'</span>';
33
	echo '<div class="entry-content">' . wp_trim_words( $content , '27' ) . '</div>';
34
	echo '<div class="read-more">';
35
	echo '<a href="' . get_permalink() . ' " class="btn read-more-btn">View Article</a>';
36
	echo '</div>';
37
	echo '</div></div>';
38
39
	endwhile;
40
	wp_reset_postdata();
41
	endif;
42
43
	echo '</div></div>';
44
45
	$output = ob_get_clean();
46
	return $output;
47
}
48
49
add_shortcode('recent_posts','recent_post_slider');
50
51
52
/**
53
 * Shortcode: Recent Post Slider
54
 */
55
function member_logo_slider($atts, $content = null){
56
57
	ob_start();
58
59
	echo '<div class="members-logo row"> <div id="logo-slider" class="owl-carousel">';
60
61
	if( have_rows('members_logo', 'option') ):
62
		while ( have_rows('members_logo', 'option') ) : the_row();
63
	$logo_url = get_sub_field('logo');
64
	$company_link = get_sub_field('link');
65
66
	echo '<div class="thumbnail thumbnail-hover">';
67
	echo '<img class="img-responsive" src=" ' . $logo_url . '">';
68
	echo '<a href=" ' . $company_link .' " " title=" ' .  $company_link .' " class="link-full"></a>';
69
	echo '</div>';
70
71
	endwhile;
72
	else :
73
		echo '<div class="col-xs-12">Members Logo Slider not found! <be> please add some logo in theme setting page</div>';
74
	endif;
75
	echo '</div></div>';
76
77
	$output = ob_get_clean();
78
	return $output;
79
}
80
81
add_shortcode('members_logo','member_logo_slider');
82
83
84
/**
85
 * Shortcode: Share Price
86
 */
87
function share_price_feed($atts, $content = null){
0 ignored issues
show
The parameter $atts is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $content is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
88
89
	ob_start();
90
91
	$xmldat = file_get_contents('http://qfx.quartalflife.com/clients/uk/lighthouse_group/xml/xml.aspx');
92
	file_put_contents('./wp-content/themes/lighthouse/xml-feeds/share-price.xml', $xmldat);
93
94
	$url 	= './wp-content/themes/lighthouse/xml-feeds/share-price.xml';
95
	$xml 	= simplexml_load_file($url);
96
	$price 	= $xml->CurrentPrice;
0 ignored issues
show
The property CurrentPrice does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
97
	$change = $xml->Change;
0 ignored issues
show
The property Change does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
98
	$change_pcent 	= $xml->PercentageChange;
0 ignored issues
show
The property PercentageChange does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
$change_pcent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
99
	$volume = $xml->Volume;
0 ignored issues
show
The property Volume does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
100
	$Date 	= $xml->Date; 
0 ignored issues
show
The property Date does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
101
	$time 	= $xml->time; 
0 ignored issues
show
The property time does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
102
103
	echo '<div class="share_price_feed">';
104
105
	echo '<div class="feed_options"><div class="share_data_title">Share Price:</div><div class="share_data">' . $price . '</div></div>';
106
	echo '<div class="feed_options"><div class="share_data_title">Change:</div><div class="share_data">' . $change . 'p</div></div>';
107
	echo '<div class="feed_options"><div class="share_data_title">Volume:</div><div class="share_data">' . $volume . '</div></div>';
108
	echo '<div class="feed_options"><div class="share_data_title">Date:</div><div class="share_data">' . $Date . '</div></div>';
109
	echo '<div class="feed_options"><div class="share_data_title">Time:</div><div class="share_data">' . $time . '</div></div>';
110
111
	echo '</div>';
112
113
	$output = ob_get_clean();
114
	return $output;
115
}
116
117
add_shortcode('share_price','share_price_feed');
118
119
120
121
/**
122
 * Shortcode: RNS Feeds
123
 */
124
function rns_feed_fn($atts, $content = null){
0 ignored issues
show
The parameter $atts is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $content is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
125
126
	ob_start();
127
128
	$xmldata = file_get_contents('http://otp.investis.com/clients/uk/lighthouse_group_plc/rns/xml-feed.aspx?culture=en-GB');
129
	file_put_contents('./wp-content/themes/lighthouse/xml-feeds/rns-feed.xml', $xmldata);
130
131
	$url 	= './wp-content/themes/lighthouse/xml-feeds/rns-feed.xml';
132
	$xml 	= simplexml_load_file($url);
133
134
	foreach ($xml->RNSSummaries->RNSSummary as $RNSSummary) {
135
		$RNSDateTime = $RNSSummary->publishDate;
136
		$RNSDate = substr($RNSDateTime, 5, 11);
137
		$RNSLink = $RNSSummary->ShareURL;
138
		$RNSTitle = $RNSSummary->Title;
139
140
		echo $RNSDate, ' – <a title="Read article" href=" ', $RNSLink, ' " target="_blank"> ', $RNSTitle, ' </a><br> ', PHP_EOL;
141
	}
142
143
	$output = ob_get_clean();
144
	return $output;
145
}
146
147
add_shortcode('rns_feed','rns_feed_fn');