1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress Custom Taxonomy Help

Discussion in 'General Programming Chat' started by cody41, Sep 9, 2013.

  1. cody41

    cody41 Power Member

    Joined:
    Jun 18, 2009
    Messages:
    682
    Likes Received:
    274
    Location:
    Texas
    Hey guys,
    Thought about doing a freelance gig for this, but i want to learn! I've got a plugin that submits out my posts and pages to various social sites (facebook, linkedin, plurk, twitter, etc). However, it's only doing it for my standard posts and pages, and NOT my custom posts within the custom taxonomy listing.

    I'm running Vantage as a directory website and every new listing goes into a post taxonomy called LISTING.

    When the plugin executes the push of the info out to the various social media sites, it just pushes post or page info..nothing in regards to the LISTING taxonomy.

    Here's an example of one of the social media code pieces..


    Code:
     public static function update($post_ID)    {
            //If this time Microblog Poster is disabled return immediatelly
        if ($_POST['microblogposteroff'] == "on")
            {
                return;
            }
            
            
            $post_categories = wp_get_post_categories($post_ID);
            
            if(is_array($post_categories) && !empty($post_categories))
            {
                $excluded_categories_name = "microblogposter_excluded_categories";
                $excluded_categories_value = get_option($excluded_categories_name, "");
                $excluded_categories = json_decode($excluded_categories_value, true);
                if(is_array($excluded_categories) && !empty($excluded_categories))
                {
                    foreach($excluded_categories as $cat_id)
                    {
                        if(in_array($cat_id, $post_categories))
                        {
                            return;
                        }
                    }
                }
            }
            
            
            $post = get_post($post_ID);
            $post->post_content = strip_tags($post->post_content);
            $post->post_content = preg_replace("|(\r\n)+|", " ", $post->post_content);
            $post->post_content = preg_replace("|(\t)+|", "", $post->post_content);
            $post->post_content = preg_replace("|\&nbsp\;|", "", $post->post_content);
            $post_content_actual = $post->post_content;
            $post_content_actual_lkn = substr($post_content_actual, 0, 300);
            
            
            $post_thumbnail_id = get_post_thumbnail_id($post_ID);
            $featured_image_src = '';
            if($post_thumbnail_id)
            {
                $image_attributes = wp_get_attachment_image_src($post_thumbnail_id, 'thumbnail');
                $featured_image_src_thumbnail = $image_attributes[0];
                $image_attributes = wp_get_attachment_image_src($post_thumbnail_id, 'medium');
                $featured_image_src_medium = $image_attributes[0];
            }
            
        $post_title = $post->post_title;
            $post_title = substr($post_title, 0, 110);
            if(strlen($post_title) == 110)
            {
                $post_title = substr($post_title, 0, strrpos($post_title, " "));
                $post_title .= "...";
            }
            $permalink = get_permalink($post_ID);
        $update = $post_title . " $permalink";
            
            $post_content = array();
            $post_content[] = home_url();
            $post_content[] = $post_title;
            $post_content[] = $permalink;
            
            $bitly_api = new MicroblogPoster_Bitly();
            $bitly_api_user_value = get_option("microblogposter_plg_bitly_api_user", "");
            $bitly_api_key_value = get_option("microblogposter_plg_bitly_api_key", "");
            $bitly_access_token_value = get_option("microblogposter_plg_bitly_access_token", "");
            if( ($bitly_api_user_value and $bitly_api_key_value) or $bitly_access_token_value )
            {
                $bitly_api->setCredentials($bitly_api_user_value, $bitly_api_key_value, $bitly_access_token_value);
                $shortened_permalink = $bitly_api->shorten($permalink);
                if($shortened_permalink)
                {
                    $update = $post_title . " $shortened_permalink";
                    $permalink = $shortened_permalink;
                    $post_content[] = $shortened_permalink;
                }
            }
        
        
        $tags = "";
        $posttags = get_the_tags($post_ID);
        if ($posttags) {
            foreach($posttags as $tag) {
                $tags .= $tag->slug . ','; 
            }
        }
        $tags = rtrim($tags,',');
            
            @ini_set('max_execution_time', '0');
            
            MicroblogPoster_Poster::update_twitter($update, $post_content, $post_ID);
            MicroblogPoster_Poster::update_plurk($update, $post_content, $post_ID);
        MicroblogPoster_Poster::update_delicious($post_title, $permalink, $tags, $post_content, $post_ID);
            MicroblogPoster_Poster::update_friendfeed($post_title, $permalink, $post_content, $post_ID);
            MicroblogPoster_Poster::update_facebook($update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_lkn, $featured_image_src_thumbnail);
            MicroblogPoster_Poster::update_diigo($post_title, $permalink, $tags, $post_content, $post_ID);
            MicroblogPoster_Poster::update_linkedin($update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_lkn, $featured_image_src_medium);
            
            MicroblogPoster_Poster::maintain_logs();
        }
    
    -----------------
    
    I'm guessing that this is the lynchpin and I need to somehow weave some arguments into the line:
    
      $post = get_post($post_ID);
    
    Any ideas?
     
  2. mirajkadam

    mirajkadam Regular Member

    Joined:
    Jul 18, 2013
    Messages:
    245
    Likes Received:
    38
    Occupation:
    SEO
    Location:
    Mumbai
    Ya check with it!