function pinim_metabox_content($post) { $metas = pinim_get_pin_meta(); ?> <table id="pinterest-list-table"> <thead> <tr> <th class="left"><?php _ex('Name', 'meta name'); ?> </th> <th><?php _e('Value'); ?> </th> </tr> </thead> <tbody> <?php foreach ($metas as $meta_key => $meta) { $content = null; switch ($meta_key) { case 'pin_id': $meta_key = __('Pin URL', 'pinim'); $links = array(); $links_str = null; foreach ((array) $meta as $pin_id) { $pin_url = pinim_get_pin_url($pin_id); $links[] = '<a href="' . $pin_url . '" target="_blank">' . $pin_url . '</a>'; } $content = implode('<br/>', $links); break; case 'log': //nothing for now break; default: $content = $meta[0]; break; } if ($content) { ?> <tr class="alternate"> <td class="left"> <?php echo $meta_key; ?> </td> <td> <?php echo $content; ?> </td> </tr> <?php } } ?> </tbody> </table> <?php }
function set_post_content($post) { $post_format = get_post_format($post->ID); $link = $this->get_datas('link'); $domain = $this->get_datas('domain'); $content = null; $log = pinim_get_pin_meta('log', $post->ID, true); switch ($post_format) { case 'image': $content = get_the_post_thumbnail($post->ID, 'full'); $content = '<a href="' . $link . '" title="' . the_title_attribute('echo=0') . '" >' . $content . '</a>'; break; case 'video': //https://codex.wordpress.org/Embeds $content = $link; break; } $content .= "\n"; //line break (avoid problems with embeds) $content .= '<p class="pinim-pin-source"><a href="' . $link . '" title="' . $domain . '" >' . $domain . '</a></p>'; //allow to filter $content = apply_filters('pinim_get_post_content', $content, $post, $this); //print_r("<xmp>".$content."</xmp>");exit; $my_post = array(); $my_post['ID'] = $post->ID; $my_post['post_content'] = $content; if (!wp_update_post($my_post)) { return false; } return true; }