Completed
Push — master ( d71a73...8db731 )
by Md. Mozahidur
03:18
created

shortcodes.php ➔ announcement_slider()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
nc 2
nop 2
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php 
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 31.

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.

Loading history...
2
3
4
/**
5
 * Shortcode: Announcement Slider
6
 */
7
function announcement_slider($atts, $content = null){
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
8
9
	ob_start();
10
11
	echo '<div class="messages"> <div id="announcement_slider" class="owl-carousel">';
12
13
	if( have_rows('announcement', 'option') ):
0 ignored issues
show
Documentation introduced by
'option' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
14
		while ( have_rows('announcement', 'option') ) : the_row();
0 ignored issues
show
Documentation introduced by
'option' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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){
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
39
40
	ob_start();
41
42
	echo '<div class="post-slider row"><div id="recent-posts" class="owl-carousel">';
43
44
	global $post;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
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){
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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
	echo '<div class="members-logo row"> <div id="logo-slider" class="owl-carousel">';
92
93
	if( have_rows('members_logo', 'option') ):
0 ignored issues
show
Documentation introduced by
'option' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
94
		while ( have_rows('members_logo', 'option') ) : the_row();
0 ignored issues
show
Documentation introduced by
'option' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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){
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
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;
0 ignored issues
show
Bug introduced by
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...
129
	$change = $xml->Change;
0 ignored issues
show
Bug introduced by
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...
130
	$change_pcent 	= $xml->PercentageChange;
0 ignored issues
show
Bug introduced by
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...
Unused Code introduced by
$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...
131
	$volume = $xml->Volume;
0 ignored issues
show
Bug introduced by
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...
132
	$Date 	= $xml->Date; 
0 ignored issues
show
Bug introduced by
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...
133
	$time 	= $xml->time; 
0 ignored issues
show
Bug introduced by
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...
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){
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
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');