Support » Plugin: LinkedIn Company Updates » Fixed Code

  • I have updated the below function to fix the ID issue by adding $i=1; and also putting a wrapper around the details and article area.

    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>‘ . __( ‘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 = ‘‘;

    }

    }

    // Filter the content for links
    $update_content = preg_replace(‘!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%_+.~#?&;//=]+)!i’, ‘$1‘, $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 .= ‘‘;
    $company_updates .= ‘<span>’;
    $company_updates .= ‘<i>’ . $time_ago . ‘</i>’;
    $company_updates .= ‘‘ . __( ‘view on linkedin’, ‘company-updates-for-linkedin’ ) . ‘‘;
    $company_updates .= ‘</span>’;
    $company_updates .= ‘</div>’;
    $company_updates .= ‘<div class=”wrapper-article”>’;
    $company_updates .= $img;
    $company_updates .= ‘<h3>options[‘company-id’] . ‘”>’ . $update[‘updateContent’][‘company’][‘name’] . ‘</h3>’;
    $company_updates .= ‘<p>’ . $update_content . ‘</p>’;
    $company_updates .= ‘</div>’;
    $company_updates .= ‘‘;
    $i++;
    }
    } else {
    $company_updates .= ‘

  • ‘ . __( ‘Sorry, no posts were received from LinkedIn!’, ‘company-updates-for-linkedin’ ) . ‘
  • ‘;
    }
    $company_updates .= ‘‘;

    return $company_updates;
    }

    }

  • The topic ‘Fixed Code’ is closed to new replies.