WordPress.org

Plugin Directory

Opened 5 weeks ago

Closed 5 weeks ago

#2674 closed enhancement (duplicate)

Function Fixes

Reported by: rawmarketing2017 Owned by:
Priority: high Severity: normal
Plugin: not-listed Keywords:
Cc:

Description

Have added incrementation ($i=1;) to fix the id="linkedin-item" (now it's id="linkedin-item-1") issue, ID's are meant to be unique, also have put a wrapper around the details and article for better css styling.

public function get_updates( $atts ) {

			// Set up shortcode attributes
			$args = shortcode_atts( array(
				'con_class'  => isset( $this->options['update-items-container-class'] ) ? $this->options['update-items-container-class'] : '',
				'item_class' => isset( $this->options['update-item-class'] ) ? $this->options['update-item-class'] : '',
				'company'    => isset( $this->options['company-id'] ) ? $this->options['company-id'] : '',
				'limit'      => isset( $this->options['limit'] ) ? $this->options['limit'] : '',
			), $atts );

			// Set up options
			$company_id = $args['company'];

			// Make sure auth token isn't expired
		    if ( $this->token_life ) {

		    	// make some linkedin api calls
				$array_updates = $this->linkedin_api_call( $company_id . '/updates', 'values', array( 'count' => $args['limit'], 'event-type' => 'status-update' ) );
				$logo_url      = $this->linkedin_api_call( $company_id . ':(id,name,ticker,description,square-logo-url)', 'squareLogoUrl', array() );

				// Build the list of updates
				$company_updates = '<ul id="linkedin-con" class="' . $args['con_class'] . '">';
				$company_updates .= '	<h2><img src="' . plugins_url( 'img/linkedin-logo.gif', __FILE__ ) . '" />' . __( 'LinkedIn Company Updates', 'company-updates-for-linkedin' ) . '</h2>';
				if ( $array_updates ) {
					$i=1;
					foreach ($array_updates as $update) {

						// Set up the time ago strings
						$update_share = $update['updateContent']['companyStatusUpdate']['share'];
						$time_ago = $this->time_ago( $update_share['timestamp'] );

						// Add picture if there is one
						$img = '';
						if( array_key_exists( 'content', $update_share ) ) {
							$shared_content = $update_share['content'];

							if( array_key_exists( 'submittedImageUrl', $shared_content ) 
								&& 'https://static.licdn.com/scds/common/u/img/spacer.gif' !== $shared_content['submittedImageUrl'] ) {

									$update_image_url = $shared_content['submittedImageUrl'];
									$update_image_link = $shared_content['submittedUrl'];

									$img = '<a target="_blank" href="' . $update_image_link . '"><img alt="" class="linkedin-update-image" src="' . $update_image_url . '" /></a>';

							}

						}

						// Filter the content for links
						$update_content = preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%_+.~#?&;//=]+)!i', '<a target="_blank" href="$1">$1</a>', $update_share['comment']);

						// Create the link to the post
						$update_pieces = explode( '-', $update['updateKey'] );
						$update_id = end( $update_pieces );
						$update_url = 'https://www.linkedin.com/nhome/updates?topic=' . $update_id;

						// Add this item to the update string
						$company_updates .= '<li id="linkedin-item-' . $i . '" class="' . $args['item_class'] . '">';
						$company_updates .= 	'<div class="wrapper-details">';
						$company_updates .= 		'<img class="linkedin-update-logo" src="' . $logo_url . '" />';
						$company_updates .= 		'<span>';
						$company_updates .= 			'<i>' . $time_ago . '</i>';
						$company_updates .= 			'<a target="_blank" href="' . $update_url . '">' . __( 'view on linkedin', 'company-updates-for-linkedin' ) . '</a>';
						$company_updates .= 		'</span>';
						$company_updates .= 	'</div>';
						$company_updates .= 	'<div class="wrapper-article">';
						$company_updates .= 		$img;
						$company_updates .= 		'<h3><a target="_blank" href="https://www.linkedin.com/company/' . $this->options['company-id'] . '">' . $update['updateContent']['company']['name'] . '</a></h3>';
						$company_updates .= 		'<p>' . $update_content . '</p>';
						$company_updates .= 	'</div>';
						$company_updates .= '</li>';
						$i++;
					}
				} else {
					$company_updates .= '<li>' . __( 'Sorry, no posts were received from LinkedIn!', 'company-updates-for-linkedin' ) . '</li>';
				}
				$company_updates .= '</ul>';

				return $company_updates;
			}

		}

Change History (1)

comment:1 @rawmarketing20175 weeks ago

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.