function tdomf_widget_getcat_post($args, $params)
{
    global $tdomf_getcat_overwrite, $tdomf_getcat_var_name;
    extract($args);
    if (isset($args[$tdomf_getcat_var_name])) {
        // Overwrite existing post categories
        //
        if ($tdomf_getcat_overwrite) {
            $post_cats = array($args[$tdomf_getcat_var_name]);
        } else {
            // Append to existing categories
            //
            // Grab existing data
            $post = wp_get_single_post($post_ID, ARRAY_A);
            $current_cats = $post['post_category'];
            // Now merge existing categories with new category
            $post_cats = array_merge($current_cats, array($args[$tdomf_getcat_var_name]));
        }
        // Update categories on post
        $post = array("ID" => $post_ID, "post_category" => $post_cats);
        wp_update_post($post);
    }
    // no errors so return NULL
    return NULL;
}
 function OnPrePageLoad()
 {
     $this->SetPageTitle(wp_title('', false) . ' – ' . get_bloginfo('name', 'display'));
     if (has_excerpt()) {
         $this->SetPageDescription(get_the_excerpt());
     } else {
         $description = wp_get_single_post(get_the_id())->post_content;
         $description = strip_tags($description);
         $break = strpos($description, "\n");
         if ($break !== false and $break > 0) {
             $description = substr($description, 0, $break - 1);
         }
         $this->SetPageDescription($description);
     }
     $this->SetContentConstraint($this->ConstrainColumns());
     $this->SetContentCssClass('hasLargeImage');
 }
Example #3
0
function excerpt_to_description()
{
    global $post;
    // get access to the $post object
    if (is_single() || is_page()) {
        // only run on posts or pages
        $all_post_content = wp_get_single_post($post->ID);
        // get all content from the post/page
        $excerpt = substr($all_post_content->post_content, 0, 100) . ' [...]';
        // get first 100 characters and append "[...]" to the end
        echo "<meta name='description' content='" . $excerpt . "' />\r\n";
        // add meta tag to <head>
    } else {
        // only run if not a post or page
        echo "<meta name='description' content='" . get_bloginfo('description') . "' />\r\n";
        // add meta tag to <head>
    }
}
 function post($args, $options, $postfix = '')
 {
     global $wpdb;
     extract($args);
     $form_data = tdomf_get_form_data($tdomf_form_id);
     $modifypost = false;
     if ($options['post-title'] || $options['a'] || $options['img'] || $options['attach-a'] || $options['attach-thumb-a'] || $options['thumb-a']) {
         // Grab existing data
         $post = wp_get_single_post($post_ID, ARRAY_A);
         if (!empty($post['post_content'])) {
             $post = add_magic_quotes($post);
         }
         $content = $post['post_content'];
         $title = $post['post_title'];
         $cats = $post['post_category'];
     }
     $filecount = 0;
     $theirfiles = $form_data['uploadfiles_' . $tdomf_form_id . '_' . $postfix];
     for ($i = 0; $i < $options['max']; $i++) {
         if (!file_exists($theirfiles[$i]['path'])) {
             unset($theirfiles[$i]);
         } else {
             $filecount++;
             // move file
             $postdir = $options['path'] . DIRECTORY_SEPARATOR . $post_ID;
             tdomf_recursive_mkdir($postdir, TDOMF_UPLOAD_PERMS);
             $newpath = $postdir . DIRECTORY_SEPARATOR . $theirfiles[$i]['name'];
             if (rename($theirfiles[$i]['path'], $newpath)) {
                 $newpath = realpath($newpath);
                 // to support multiple files, we have to avoid clashes without instances
                 $j = $this->getFreeIndexPostMeta($post_ID, TDOMF_KEY_DOWNLOAD_PATH, $i);
                 // store info about files on post
                 //
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_COUNT . $j, 0, true);
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_TYPE . $j, $theirfiles[$i]['type'], true);
                 // escape the "path" incase it contains '\' as WP will strip these out!
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_PATH . $j, $wpdb->escape($newpath), true);
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_NAME . $j, $theirfiles[$i]['name'], true);
                 // keep a list of the uploaded/created files
                 //
                 $this->addToFileList($post_ID, $postfix, $newpath);
                 tdomf_log_message("File " . $theirfiles[$i]['name'] . " saved from tmp area to " . $newpath . " with type " . $theirfiles[$i]['type'] . " for post {$post_ID}");
                 // Execute user command
                 //
                 if ($options['cmd'] != "") {
                     $cmd_output = shell_exec($options['cmd'] . " " . $newpath);
                     tdomf_log_message("Executed user command on file {$newpath}<br/><pre>{$cmd_output}</pre>");
                     add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_CMD_OUTPUT . $i, $cmd_output, true);
                 }
                 // Use direct links or wrapper
                 //
                 if ($options['nohandler'] && trim($options['url']) != "") {
                     $uri = trailingslashit($options['url']) . "{$post_ID}/" . $theirfiles[$i]['name'];
                 } else {
                     $uri = trailingslashit(get_bloginfo('wpurl')) . '?tdomf_download=' . $post_ID . '&id=' . $i;
                 }
                 // Modify Post
                 //
                 // modify post title
                 if ($options['post-title']) {
                     $modifypost = true;
                     $title = $theirfiles[$i]['name'];
                 }
                 // add download link (inc name and file size)
                 if ($options['a']) {
                     $modifypost = true;
                     // $content .= "<p><a href=\"$uri\">".$theirfiles[$i]['name']." (".tdomf_filesize_format(filesize($newpath)).")</a></p>";
                 }
                 // add image link (inc name and file size)
                 if ($options['img']) {
                     $modifypost = true;
                     // Commented out image link in post by Alexander Rea 2/28/10
                     // $content .= "<p><img src=\"$uri\" /></p>";
                 }
                 // Use user-defined custom key
                 if ($options['custom'] && !empty($options['custom-key'])) {
                     add_post_meta($post_ID, $options['custom-key'], $uri);
                 }
                 // Insert upload as an attachment to post!
                 if ($options['attach']) {
                     // Create the attachment (not sure if these values are correct)
                     //
                     $attachment = array("post_content" => "", "post_title" => $theirfiles[$i]['name'], "post_name" => sanitize_title($theirfiles[$i]['name']), "post_status" => 'inherit', "post_parent" => $post_ID, "guid" => $uri, "post_type" => 'attachment', "post_mime_type" => $theirfiles[$i]['type'], "menu_order" => $i, "post_category" => $cats);
                     // I dont' know if this is a wp2.8 thing, but you have to
                     // URI for it to be properly handled as an attachment, yet...
                     // how does it know where to generate the thumbs?
                     $attachment_ID = wp_insert_attachment($attachment, $uri, $post_ID);
                     // Weirdly, I have to do this now to access the wp_generate_attachement_metadata
                     // functino from within the widget class
                     //
                     require_once ABSPATH . 'wp-admin/includes/image.php';
                     // Generate meta data (which includes thumbnail!)
                     //
                     $attachment_metadata = wp_generate_attachment_metadata($attachment_ID, $newpath);
                     // add link to attachment page
                     if ($options['attach-a']) {
                         $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\">" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")</a></p>";
                     }
                     if (tdomf_wp23()) {
                         // Did Wordpress generate a thumbnail?
                         if (isset($attachment_metadata['thumb'])) {
                             // Wordpress 2.3 uses basename and generates only the "name" of the thumb,
                             // in general it creates it in the same place as the file!
                             $thumbpath = $postdir . DIRECTORY_SEPARATOR . $attachment_metadata['thumb'];
                             if (file_exists($thumbpath)) {
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMB . $j, $thumbpath, true);
                                 // add to list
                                 //
                                 $this->addToFileList($post_ID, $postfix, $thumbpath);
                                 // WARNING: Don't modify the 'thumb' as this is used by Wordpress to know
                                 // if there is a thumb by using basename and the file path of the actual file
                                 // attachment
                                 //
                                 // Use direct links *or* wrapper
                                 //
                                 if ($options['nohandler'] && trim($options['url']) != "") {
                                     $thumburi = $options['url'] . "/{$post_ID}/" . $attachment_metadata['thumb'];
                                 } else {
                                     $thumburi = get_bloginfo('wpurl') . '/?tdomf_download=' . $post_ID . '&id=' . $j . '&thumb';
                                 }
                                 // store a copy of the thumb uri
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMBURI . $j, $thumburi, true);
                                 //$attachment_metadata['thumb'] = $thumb_uri;
                                 //$attachment_metadata['thumb'] = $thumbpath;
                                 // add thumbnail link to attachment page
                                 if ($options['attach-thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add thumbnail link directly to file
                                 if ($options['thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"{$uri}\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                             } else {
                                 tdomf_log_message("Could not find thumbnail {$thumbpath}!", TDOMF_LOG_ERROR);
                             }
                         }
                     } else {
                         // In Wordpress 2.5 the attachment data structure is changed,
                         // it only generates a thumbnail if it needs to...
                         // Medium sized images can also sometimes be created, make a note of it
                         //
                         if (isset($attachment_metadata['sizes']['medium'])) {
                             $medpath = $postdir . DIRECTORY_SEPARATOR . $attachment_metadata['sizes']['medium']['file'];
                             if (file_exists($medpath)) {
                                 $this->addToFileList($post_ID, $postfix, $medpath);
                             }
                         }
                         if (isset($attachment_metadata['sizes']['thumbnail'])) {
                             $thumbpath = $postdir . DIRECTORY_SEPARATOR . $attachment_metadata['sizes']['thumbnail']['file'];
                             if (file_exists($thumbpath)) {
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMB . $j, $thumbpath, true);
                                 // add to list
                                 //
                                 $this->addToFileList($post_ID, $postfix, $thumbpath);
                                 // Use direct links *or* wrapper
                                 //
                                 if ($options['nohandler'] && trim($options['url']) != "") {
                                     $thumburi = $options['url'] . "/{$post_ID}/" . $attachment_metadata['sizes']['thumbnail']['file'];
                                 } else {
                                     $thumburi = get_bloginfo('wpurl') . '/?tdomf_download=' . $post_ID . '&id=' . $j . '&thumb';
                                 }
                                 // store a copy of the thumb uri
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMBURI . $j, $thumburi, true);
                                 // add thumbnail link to attachment page
                                 if ($options['attach-thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add thumbnail link directly to file
                                 if ($options['thumb-a']) {
                                     $modifypost = true;
                                     $content .= "<p><a href=\"{$uri}\"><img src=\"{$thumburi}\" alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                             } else {
                                 tdomf_log_message("Could not find thumbnail {$thumbpath}!", TDOMF_LOG_ERROR);
                             }
                         } else {
                             if (wp_attachment_is_image($attachment_ID) && ($options['attach-thumb-a'] || $options['thumb-a'])) {
                                 // Thumbnail not generated automatically, this means that the image
                                 // is smaller than a thumbnail => use as thumbnail
                                 tdomf_log_message("No thumbnail created => image is too small. Use image as thumbnail.", TDOMF_LOG_ERROR);
                                 $modifypost = true;
                                 $sizeit = "";
                                 $h = get_option("thumbnail_size_h");
                                 $w = get_option("thumbnail_size_w");
                                 if ($attachment_metadata['height'] > $h || $attachment_metadata['width'] > $w) {
                                     if ($attachment_metadata['height'] > $attachment_metadata['width']) {
                                         $sizeit = " height=\"{$h}px\" ";
                                     } else {
                                         $sizeit = " height=\"{$w}px\" ";
                                     }
                                 }
                                 // store a the uri as a the thumburi
                                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_THUMBURI . $j, $uri, true);
                                 // add thumbnail link to attachment page
                                 if ($options['attach-thumb-a']) {
                                     $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\"><img src=\"{$uri}\" {$sizeit} alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></a></p>";
                                 }
                                 // add just the image (no point linking to thumbnail)
                                 if ($options['thumb-a']) {
                                     $content .= "<p><img src=\"{$uri}\" {$sizeit} alt=\"" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")\" /></p>";
                                 }
                             }
                         }
                     }
                     // Add meta data
                     //
                     wp_update_attachment_metadata($attachment_ID, $attachment_metadata);
                     tdomf_log_message("Added " . $theirfiles[$i]['name'] . " as attachment");
                 }
             } else {
                 tdomf_log_message("Failed to move " . $theirfiles[$i]['name'] . "!", TDOMF_LOG_ERROR);
                 return __("Failed to move uploaded file from temporary location!", "tdomf");
             }
         }
     }
     if ($modifypost) {
         tdomf_log_message("Attempting to update post with file upload info");
         $post = array("ID" => $post_ID, "post_content" => $content, "post_title" => $title, "post_name" => sanitize_title($title));
         sanitize_post($post, "db");
         wp_update_post($post);
     }
     return NULL;
 }
Example #5
0
 function loadAdminPostFonts($data = false)
 {
     global $wp_query;
     if ($data) {
         if (!$data['post_content']) {
             return;
         }
         $post_content = $data['post_content'];
     } else {
         if (is_object($wp_query) && is_object($wp_query->post) && $wp_query->post->ID) {
             $post = wp_get_single_post($wp_query->post->ID);
         } else {
             if (isset($_GET['post']) && is_numeric($_GET['post'])) {
                 $post = wp_get_single_post($_GET['post']);
             } else {
                 if (isset($_GET['page']) && is_numeric($_GET['page'])) {
                     $post = wp_get_single_post($_GET['page']);
                 } else {
                     if (isset($_GET['p']) && is_numeric($_GET['p'])) {
                         $post = wp_get_single_post($_GET['page']);
                     } else {
                         return;
                     }
                 }
             }
         }
         $post_content = $post->post_content;
     }
     preg_match_all('/fontplugin_fontid_([0-9]*)_([a-zA-Z0-9]*)/', $post_content, $searchResults);
     $fontsIds = array_values(array_unique($searchResults[1]));
     $fontsNames = array_values(array_unique($searchResults[2]));
     for ($i = 0; $i < count($fontsIds); $i++) {
         $fontPairs[$fontsIds[$i]] = $fontsNames[$i];
     }
     return $fontPairs;
 }
Example #6
0
 /**
  * Process conditionals for posts.
  *
  * @since 2.2.0
  */
 function process_conditionals()
 {
     if (empty($this->params)) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
         return;
     }
     switch ($this->params[0]) {
         case $this->ENTRY_PATH:
             global $post;
             $post = wp_get_single_post($this->params[1]);
             $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
             $post = NULL;
             break;
         case $this->ENTRIES_PATH:
             $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             break;
         default:
             return;
     }
     $wp_etag = md5($wp_last_modified);
     @header("Last-Modified: {$wp_last_modified}");
     @header("ETag: {$wp_etag}");
     // Support for Conditional GET
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     } else {
         $client_etag = false;
     }
     $client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     // If string is empty, return 0. If not, attempt to parse into a timestamp
     $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
     // Make a timestamp for our most recent modification...
     $wp_modified_timestamp = strtotime($wp_last_modified);
     if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
         status_header(304);
         exit;
     }
 }
 /**
  * Process form input for widget
  * 
  * @access public
  * @return Mixed
  */
 function post($args, $options)
 {
     extract($args);
     // Grab existing data
     $post = wp_get_single_post($post_ID, ARRAY_A);
     if (!empty($post['post_excerpt'])) {
         $post = add_magic_quotes($post);
     }
     $post_excerpt = $post['post_excerpt'];
     // get user input
     $post_excerpt .= $this->textarea->post($args, $options, 'excerpt_excerpt');
     // Update actual post
     $post = array("ID" => $post_ID, "post_excerpt" => $post_excerpt);
     $post_ID = wp_update_post($post);
     return NULL;
 }
 function debug_out_feedwordpress_update_post($id)
 {
     $post = wp_get_single_post($id);
     print "[" . date('Y-m-d H:i:s') . "][feedwordpress] updated " . "'{$post->post_title}' ({$post->post_date})" . " (as of {$post->post_modified})\n";
 }
function mt_publishPost($params)
{
    global $xmlrpcusererr;
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    if (user_pass_ok($username, $password)) {
        $postdata = wp_get_single_post($post_ID, ARRAY_A);
        $postdata['post_status'] = 'publish';
        // retain old cats
        $cats = wp_get_post_cats('', $post_ID);
        $postdata['post_category'] = $cats;
        $result = wp_update_post($postdata);
        return new xmlrpcresp(new xmlrpcval($result, 'boolean'));
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
 /**
  * Process form input for widget
  * 
  * @access public
  * @return Mixed
  */
 function post($args, $options)
 {
     extract($args);
     // if sumbitting a new post (as opposed to editing)
     // make sure to *append* to post_content. For editing, overwrite.
     //
     if (TDOMF_Widget::isSubmitForm($mode)) {
         // Grab existing data
         $post = wp_get_single_post($post_ID, ARRAY_A);
         if (!empty($post['post_content'])) {
             $post = add_magic_quotes($post);
         }
         // Append
         $post_content = $post['post_content'];
         $post_content .= $this->textarea->post($args, $options, 'content_content');
     } else {
         // $mode startswith "edit-"
         // Overwrite
         $post_content = $this->textarea->post($args, $options, 'content_content');
     }
     // Title
     if ($options['title-enable']) {
         $content_title = tdomf_protect_input($this->textfield->post($args, $options, 'content_title'));
     }
     // Update actual post
     $post = array("ID" => $post_ID, "post_content" => $post_content);
     if ($options['title-enable']) {
         $post["post_title"] = $content_title;
         $post["post_name"] = sanitize_title($content_title);
     }
     $post_ID = wp_update_post($post);
     return NULL;
 }
Example #11
0
function express_editPost($args)
{
    global $wp_xmlrpc_server;
    $args = express_woo_taxonomy($args);
    $result = $wp_xmlrpc_server->mw_editPost($args);
    if ($result == false) {
        return false;
    }
    // Insert taxonomies
    if (isset($content_struct['taxonomy'])) {
        set_new_taxonomy_tag($post_ID, $content_struct['taxonomy']);
    }
    // TODO: Remove old attachments
    // Add new attachments
    $post_ID = (int) $args[0];
    $content_struct = $args[3];
    $attachments = $content_struct['attachments'];
    if (is_array($attachments)) {
        foreach ($attachments as $attachment_ID) {
            $attachment_post = wp_get_single_post($attachment_ID, ARRAY_A);
            extract($attachment_post, EXTR_SKIP);
            $post_parent = $post_ID;
            $postdata = compact('ID', 'post_parent', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
            wp_update_post($postdata);
        }
    }
    return true;
}
 function post_settings_delete()
 {
     global $wpdb;
     extract($_POST);
     // check
     $post_id = $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id));
     // if post
     if ((int) $post_id > 0) {
         // update content
         // get content
         $wp_post = wp_get_single_post($post_id);
         // update
         wp_update_post(array('post_content' => preg_replace('/\\[\\/?private\\]/', '', $wp_post->post_content), 'ID' => $wp_post->ID));
         // remove other Issue #922
         // get object
         $post_obj = mgm_get_post($post_id);
         // set
         $post_obj->purchasable = 'N';
         $post_obj->purchase_cost = '0.00';
         $post_obj->access_membership_types = array();
         // save meta
         $post_obj->save();
         // unset
         unset($post_obj);
     }
     // sql
     $sql = $wpdb->prepare("DELETE FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id);
     // delete
     if ($wpdb->query($sql)) {
         $message = __('Successfully deleted post settings: ', 'mgm');
         $status = 'success';
     } else {
         $message = __('Error while deleting post settings: ', 'mgm');
         $status = 'error';
     }
     // return response
     echo json_encode(array('status' => $status, 'message' => $message));
 }
Example #13
0
/**
 * Unspams a reply
 *
 * @since bbPress (r2740)
 *
 * @param int $reply_id Reply id
 * @uses wp_get_single_post() To get the reply
 * @uses do_action() Calls 'bbp_unspam_reply' with the reply ID
 * @uses get_post_meta() To get the previous status meta
 * @uses delete_post_meta() To delete the previous status meta
 * @uses wp_insert_post() To insert the updated post
 * @uses do_action() Calls 'bbp_unspammed_reply' with the reply ID
 * @return mixed False or {@link WP_Error} on failure, reply id on success
 */
function bbp_unspam_reply($reply_id = 0)
{
    // Get reply
    $reply = wp_get_single_post($reply_id, ARRAY_A);
    if (empty($reply)) {
        return $reply;
    }
    // Bail if already not spam
    if (bbp_get_spam_status_id() != $reply['post_status']) {
        return false;
    }
    // Execute pre unspam code
    do_action('bbp_unspam_reply', $reply_id);
    // Get pre spam status
    $reply['post_status'] = get_post_meta($reply_id, '_bbp_spam_meta_status', true);
    // Delete pre spam meta
    delete_post_meta($reply_id, '_bbp_spam_meta_status');
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Update the reply
    $reply_id = wp_insert_post($reply);
    // Execute post unspam code
    do_action('bbp_unspammed_reply', $reply_id);
    // Return reply_id
    return $reply_id;
}
function ac_notifier_remove_notification_for_blog_posts()
{
    if (!(is_user_logged_in() && is_singular())) {
        return;
    }
    global $bp, $wpdb;
    $blog_id = (int) $wpdb->blogid;
    $post = wp_get_single_post();
    $activity_id = bp_activity_get_activity_id(array('user_id' => $post->post_author, 'component' => $bp->blogs->id, 'type' => "new_blog_post", "item_id" => $blog_id, 'secondary_item_id' => $post->ID));
    //delete the notification for activity comment on new_blog_post
    if (!empty($activity_id)) {
        bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $activity_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id);
    }
    //for replies on blog comments in activity stream
    $comments = ac_notifier_get_all_blog_post_comment_ids($post->ID);
    //get all the comment ids as array
    //added in v 1.0.3 for better database performance, no more looping to get individual activity ids
    $activities = ac_notifier_get_activity_ids(array("type" => "new_blog_comment", "component" => $bp->blogs->id, "item_id" => $blog_id, "secondary_ids" => $comments));
    foreach ((array) $activities as $ac_id) {
        bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $ac_id, $bp->ac_notifier->id, 'new_activity_comment_' . $ac_id);
    }
}
function tdomf_widget_comments_adminemail($args)
{
    $options = tdomf_widget_comments_get_options($args['tdomf_form_id']);
    extract($args);
    $output = "";
    $post = wp_get_single_post($post_ID, ARRAY_A);
    if ($post['comment_status'] == 'closed') {
        $output .= __("Comments off", "tdomf");
    } else {
        $output .= __("Comments on", "tdomf");
    }
    $output .= "\n";
    if ($post['ping_status'] == 'closed') {
        $output .= __("Pings and Trackbacks off", "tdomf");
    } else {
        $output .= __("Pings and Trackbacks on", "tdomf");
    }
    $output .= $after_widget;
    return $output;
}
 public function getPost($postId)
 {
     return wp_get_single_post($postId);
 }
function pfp_get_posts($pfp_opts)
{
    $params = array();
    if ($pfp_opts['post_id'] == '') {
        // for multiposts
        if ($pfp_opts['tag_slug'] != '') {
            $params['tag_slug__in'] = explode(",", $pfp_opts['tag_slug']);
        }
        if ($pfp_opts['cat'] != '') {
            $params['category__in'] = explode(",", $pfp_opts['cat']);
        }
        if ($pfp_opts['cat_slug'] != '') {
            $params['category_name'] = $pfp_opts['cat_slug'];
        }
        if ($pfp_opts['author'] != '') {
            $params['author'] = $pfp_opts['author'];
        }
        if ($pfp_opts['order_by'] != '') {
            $params['order_by'] = $pfp_opts['order_by'];
        }
        if ($pfp_opts['num'] != '') {
            //$params['numberposts'] = $pfp_opts['num'];
            $params['posts_per_page'] = $pfp_opts['num'];
            $params['paged'] = $pfp_opts['cur_page'];
            //if($pfp_opts['page_num'] != '') {
            // work out offset depending on page num
            //$offset = $pfp_opts['page_num'] * $pfp_opts['num'];
            //$params['offset'] = $offset;
            //}
        } else {
            $params['posts_per_page'] = -1;
            // gets them all
        }
        if ($pfp_opts['order'] != '') {
            $params['order'] = $pfp_opts['order'];
        }
        // apply whatever the case:
        $params['suppress_filters'] = false;
        // get the posts
        //$postslist = get_posts($params);
        $postslist = query_posts($params);
    } else {
        // for single posts
        $postslist[0] = wp_get_single_post($pfp_opts['post_id']);
    }
    return $postslist;
}
Example #18
0
 public function getPost($attr)
 {
     if ($postID = $this->get($attr)) {
         return wp_get_single_post($postID);
     }
     return new stdClass();
 }
Example #19
0
function tdomf_ham_post($post_id)
{
    if (!get_option(TDOMF_OPTION_SPAM)) {
        return;
    }
    $akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
    if (empty($akismet_key)) {
        tdomf_log_message("No Akismet key set, cannot submit ham for {$post_id}!", TDOMF_LOG_ERROR);
        return;
    }
    if (!get_post($post_id)) {
        tdomf_log_message("Post with ID {$post_id} does not exist!", TDOMF_LOG_ERROR);
        return;
    }
    if (!get_post_meta($post_id, TDOMF_KEY_FLAG, true)) {
        tdomf_log_message("{$post_id} is not managed by TDOMF - will not submit as ham!", TDOMF_LOG_BAD);
        return;
    }
    if (!get_post_meta($post_id, TDOMF_KEY_SPAM, true)) {
        tdomf_log_message("{$post_id} is not set as spam!", TDOMF_LOG_BAD);
        return;
    }
    $query_data = array();
    $query_data['user_ip'] = get_post_meta($post_id, TDOMF_KEY_IP, true);
    $query_data['user_agent'] = get_post_meta($post_id, TDOMF_KEY_USER_AGENT, true);
    $query_data['referrer'] = get_post_meta($post_id, TDOMF_KEY_REFERRER, true);
    $query_data['blog'] = get_option('home');
    $query_data['comment_type'] = 'new-submission';
    if (get_post_meta($post_id, TDOMF_KEY_USER_ID, true)) {
        $user = get_userdata(get_post_meta($post_id, TDOMF_KEY_USER_ID, true));
        $query_data['comment_author_email'] = $user->user_email;
        if (!empty($user->user_url)) {
            $query_data['comment_author_url'] = $user->user_url;
        }
        $query_data['comment_author'] = $user->display_name;
    } else {
        if (get_post_meta($post_id, TDOMF_KEY_NAME, true)) {
            $query_data['comment_author'] = get_post_meta($post_id, TDOMF_KEY_NAME, true);
        }
        if (get_post_meta($post_id, TDOMF_KEY_EMAIL, true)) {
            $query_data['comment_author_email'] = get_post_meta($post_id, TDOMF_KEY_EMAIL, true);
        }
        if (get_post_meta($post_id, TDOMF_KEY_WEB, true)) {
            $query_data['comment_author_url'] = get_post_meta($post_id, TDOMF_KEY_WEB, true);
        }
    }
    # test - should trigger spam response
    #$query_data['comment_author'] = 'viagra-test-123';
    $post_data = wp_get_single_post($post_id, ARRAY_A);
    $query_data['comment_content'] = $post_data['post_content'];
    /*if($live) {
         $ignore = array( 'HTTP_COOKIE' );
    	   foreach ( $_SERVER as $key => $value )
    	   if ( !in_array( $key, $ignore ) ) {
              $post_data["$key"] = $value;
         }
      }*/
    $query_string = '';
    foreach ($query_data as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    tdomf_log_message_extra("{$akismet_key}.rest.akismet.com/1.1/comment-check<br/>{$query_string}");
    $response = tdomf_akismet_send($query_string, $akismet_key . ".rest.akismet.com", "/1.1/submit-ham", 80);
    // unflag spam
    //
    delete_post_meta($post_id, TDOMF_KEY_SPAM);
    $spam_count = get_option(TDOMF_STAT_SPAM);
    if ($spam_count == false) {
        add_option(TDOMF_STAT_SPAM, 0);
    } else {
        update_option(TDOMF_STAT_SPAM, $spam_count--);
    }
    $submitted_count = get_option(TDOMF_STAT_SUBMITTED);
    if ($submitted_count == false) {
        add_option(TDOMF_STAT_SUBMITTED, 1);
    } else {
        update_option(TDOMF_STAT_SUBMITTED, $submitted_count++);
    }
    tdomf_log_message("{$post_id} has been submitted as ham to Akismet<br/><pre>" . var_export($response, true) . "</pre>");
}
/**
 * Converts a post with the article post-type to the post post-type
 * 
 * @param int $post_id The ID of the post to convert
 * @return void
 */
function anno_article_to_post($post_id)
{
    $post = wp_get_single_post(absint($post_id), ARRAY_A);
    if ($post['post_type'] != 'article') {
        return;
    }
    // Convert the taxonomies before inserting so we don't get default categories assigned.
    $taxonomy_conversion = array('article_tag' => 'post_tag', 'article_category' => 'category');
    foreach ($taxonomy_conversion as $from_tax => $to_tax) {
        anno_convert_taxonomies($post['ID'], $from_tax, $to_tax);
    }
    $post['post_type'] = 'post';
    $post['post_category'] = wp_get_post_categories($post['ID']);
    $post['tags_input'] = wp_get_post_tags($post['ID'], array('fields' => 'names'));
    $post_id = wp_insert_post($post);
}
function etm_when_wp_is_loaded()
{
    global $wpdb, $userdata, $wpseo_sitemaps;
    $wp_version_is_3_3 = etm_tools_version_check();
    $Header2 = '';
    $button2 = '';
    if (!empty($_REQUEST['status']) && $_REQUEST['status'] == 'save') {
        update_post_meta($_REQUEST['tmp_id'], 'ect_tran_content_' . $_REQUEST['tmp_lang'], $_REQUEST['translatede_body']);
        update_post_meta($_REQUEST['tmp_id'], 'ect_tran_title_' . $_REQUEST['tmp_lang'], $_REQUEST['translatede_header']);
        update_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_focuskw_' . $_REQUEST['tmp_lang'], $_REQUEST['tran_focuskw']);
        update_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_title_' . $_REQUEST['tmp_lang'], $_REQUEST['tran_title']);
        update_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_metadesc_' . $_REQUEST['tmp_lang'], $_REQUEST['tran_metadesc']);
        if (substr($_REQUEST['tran_permalink'], -1) != '/') {
            $_REQUEST['tran_permalink'] .= '/';
        }
        update_post_meta($_REQUEST['tmp_id'], 'ect_tran_permalink_' . $_REQUEST['tmp_lang'], $_REQUEST['tran_permalink']);
        update_post_meta($_REQUEST['tmp_id'], 'etm_content_excerpts_' . $_REQUEST['tmp_lang'], $_REQUEST['content_excerpts']);
        update_post_meta($_REQUEST['tmp_id'], 'etm_attachment_image_alt_' . $_REQUEST['tmp_lang'], $_REQUEST['attachment_image_alt']);
        $response = array('R' => 'OK', 'MSG' => 'Your translation has been saved.', 'INFOCON' => 1);
    } else {
        if (!empty($_REQUEST['status']) && $_REQUEST['status'] == 'delete') {
            delete_post_meta($_REQUEST['tmp_id'], 'ect_tran_content_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], 'ect_tran_title_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_focuskw_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_title_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_metadesc_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], 'ect_tran_permalink_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], 'etm_content_excerpts_' . $_REQUEST['tmp_lang']);
            delete_post_meta($_REQUEST['tmp_id'], 'etm_attachment_image_alt_' . $_REQUEST['tmp_lang']);
            $response = array('R' => 'OK', 'MSG' => 'Translation has been deleted');
        } else {
            $content = '';
            $sqldatalang = etm_languages_flags($_REQUEST['tmp_lang']);
            $langed_string = '<img style="float: left;padding-left: 10px;padding-top: 4px;" src="' . etm_tools_create_icons_url($sqldatalang['icon'], 2) . '" ><div style="float: left; padding-left: 10px; padding-top: 3px;"><h2 style="padding-top:0px">Translate to ' . $sqldatalang['org_name'] . ' (' . $sqldatalang['english_name'] . ')</h2></div>';
            $translations_header = get_post_meta($_REQUEST['tmp_id'], 'ect_tran_title_' . $_REQUEST['tmp_lang'], true);
            $translations_body = get_post_meta($_REQUEST['tmp_id'], 'ect_tran_content_' . $_REQUEST['tmp_lang'], true);
            $default_permalink = get_permalink($_REQUEST['tmp_id']);
            $ect_tran_permalink = get_post_meta($_REQUEST['tmp_id'], 'ect_tran_permalink_' . $_REQUEST['tmp_lang'], true);
            if (empty($translations_header)) {
                $translations_header = '';
            }
            if (empty($translations_body)) {
                $translations_body = '';
            }
            if ($wp_version_is_3_3) {
                $post_data = get_post($_REQUEST['tmp_id']);
            } else {
                $post_data = wp_get_single_post($_REQUEST['tmp_id']);
            }
            $default_header = $post_data->post_title;
            $default_body = $post_data->post_content;
            if ((!empty($default_header) || !empty($default_body)) && (current_user_can('etm_translate_' . $_REQUEST['tmp_type']) || current_user_can('manage_options'))) {
                $content .= '<div style="float:left;padding-top:10px"><input type="submit" onClick="deletePopOpControl(\'' . $_REQUEST['tmp_id'] . '\',\'' . $_REQUEST['tmp_lang'] . '\',\'' . $_REQUEST['tmp_type'] . '\')" value="Delete" class="button-secondary" name="Delete"></div>';
            }
            $content .= '<div style="float:right;padding-top:10px">';
            if (!etm_tools_version_check()) {
                $content .= '<input type="submit" value="HTML MODE" onclick="switch_html_preview(\'pp_readonly_content\',\'pp_translate_content\',this);" class="button-secondary">';
            }
            //Seo system
            $seo_plugin_by_yoast = etm_tools_retrive_options('seo_plugin_by_yoast');
            if (defined('WPSEO_VERSION') && !empty($seo_plugin_by_yoast)) {
                $content .= '<input style=" margin-left: 5px;margin-right: 20px;" type="submit" onClick="etm_switch_seo(\'#etm_table_1\',\'#etm_table_2\')" value="SEO" class="button-primary">';
                $button2 = '<input style="float:right;margin-left: 5px;" type="submit" onClick="etm_switch_seo(\'#etm_table_2\',\'#etm_table_1\')" value="Back" class="button-primary">';
                $Header2 = '<img style="float: left;padding-left: 10px;padding-top: 4px;" src="' . etm_tools_create_icons_url($sqldatalang['icon'], 2) . '" ><div style="float: left; padding-left: 10px; padding-top: 3px;"><h2 style="padding-top:0px">SEO to ' . $sqldatalang['org_name'] . ' (' . $sqldatalang['english_name'] . ')</h2></div>';
            }
            $_yoast_wpseo_focuskw = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_focuskw', true);
            $_yoast_wpseo_title = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_title', true);
            $_yoast_wpseo_metadesc = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_metadesc', true);
            $_tran_focuskw = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_focuskw_' . $_REQUEST['tmp_lang'], true);
            $_tran_title = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_title_' . $_REQUEST['tmp_lang'], true);
            $_tran_metadesc = get_post_meta($_REQUEST['tmp_id'], '_yoast_wpseo_metadesc_' . $_REQUEST['tmp_lang'], true);
            // Extra system
            $content .= '<input style=" margin-left: 5px;margin-right: 20px;" type="submit" onClick="etm_switch_seo(\'#etm_table_1\',\'#etm_table_3\')" value="Extra " class="button-primary">';
            $button3 = '<input style="float:right;margin-left: 5px;" type="submit" onClick="etm_switch_seo(\'#etm_table_3\',\'#etm_table_1\')" value="Back" class="button-primary">';
            $Header3 = '<img style="float: left;padding-left: 10px;padding-top: 4px;" src="' . etm_tools_create_icons_url($sqldatalang['icon'], 2) . '" ><div style="float: left; padding-left: 10px; padding-top: 3px;"><h2 style="padding-top:0px">Extra to ' . $sqldatalang['org_name'] . ' (' . $sqldatalang['english_name'] . ')</h2></div>';
            $post_default_content_excerpts = $post_data->post_excerpt;
            $post_default_media_alternate_text = get_post_meta($_REQUEST['tmp_id'], '_wp_attachment_image_alt', true);
            $post_translatede_content_excerpts = get_post_meta($_REQUEST['tmp_id'], 'etm_content_excerpts_' . $_REQUEST['tmp_lang'], true);
            $post_translatedet_media_alternate_text = get_post_meta($_REQUEST['tmp_id'], 'etm_attachment_image_alt_' . $_REQUEST['tmp_lang'], true);
            $content .= '<input style=" margin-left: 5px;margin-right: 20px;" type="submit" onClick="copiePopOpControl(\'#post_default_header\',\'#post_translatede_header\')" value="Copy text" class="button-secondary" name="Cancel"><input type="submit" onClick="cancelPopOpControl()" value="Cancel" class="button-secondary" name="Cancel">';
            if (current_user_can('etm_translate_' . $_REQUEST['tmp_type']) || current_user_can('manage_options')) {
                $content .= '<input onClick="savePopOpControl(\'' . $_REQUEST['tmp_id'] . '\',\'' . $_REQUEST['tmp_lang'] . '\',\'#translations_inputtext\',\'' . $_REQUEST['tmp_type'] . '\',\'#post_translatede_header\',\'#translatede_body\')" type="submit" class="button-primary" value="Save" name="Save">';
            }
            $content .= '</div>';
            $tmp = etm_languages_flags($_REQUEST['tmp_lang']);
            if (!empty($tmp['rtl']) && $tmp['rtl']) {
                $dir = 'rtl';
            } else {
                $dir = 'ltr';
            }
            $response = array('R' => 'OK', 'DIR' => $dir, 'RETURNDATA' => $content, 'langed_string' => $langed_string, 'default_header' => $default_header, 'translations_header' => $translations_header, 'default_body' => $default_body, 'translations_body' => $translations_body, 'buttons' => $content, 'buttons2' => $button2, 'yoast_wpseo_focuskw' => $_yoast_wpseo_focuskw, 'yoast_wpseo_title' => $_yoast_wpseo_title, 'yoast_wpseo_metadesc' => $_yoast_wpseo_metadesc, 'tran_focuskw' => $_tran_focuskw, 'tran_title' => $_tran_title, 'tran_metadesc' => $_tran_metadesc, 'default_heade2' => $Header2, 'tran_permalink' => $ect_tran_permalink, 'default_permalink' => $default_permalink, 'header_extra_post' => $Header3, 'post_default_content_excerpts' => $post_default_content_excerpts, 'post_translatede_content_excerpts' => $post_translatede_content_excerpts, 'post_default_media_alternate_text' => $post_default_media_alternate_text, 'post_translatedet_media_alternate_text' => $post_translatedet_media_alternate_text, 'post_buttons3' => $button3);
        }
    }
    die(json_encode($response));
}
Example #22
0
        if (strtotime($datepp) >= strtotime($_GET['from']) && strtotime($datepp) <= strtotime($_GET['to'])) {
        } else {
            continue;
        }
    }
    ?>
		<?php 
    global $wpdb;
    $con_id = 0;
    $query = "SELECT p2p_from FROM wp_p2p where p2p_to = {$post->ID} and p2p_type = 'maps_to_project'";
    $results = $wpdb->get_results($query);
    foreach ($results as $result) {
        $con_id = $result->p2p_from;
    }
    if ($con_id != 0) {
        $con_array = wp_get_single_post($con_id);
        $location = get_field('maplatlng', $con_id);
    }
    if (isset($_GET['location'])) {
        if ($_GET['location'] == 'null') {
            $_GET['location'] = 'nepal';
        }
        if (stripos($location['address'], $_GET['location']) !== false) {
        } else {
            continue;
        }
    }
    ?>
		<div class="cd-timeline-block <?php 
    if ($j == 0) {
        echo 'first';
Example #23
0
/**
 * Unspams a topic
 *
 * @since bbPress (r2740)
 *
 * @param int $topic_id Topic id
 * @uses wp_get_single_post() To get the topic
 * @uses do_action() Calls 'bbp_unspam_topic' with the topic id
 * @uses get_post_meta() To get the previous status
 * @uses delete_post_meta() To delete the previous status meta
 * @uses wp_insert_post() To update the topic with the new status
 * @uses do_action() Calls 'bbp_unspammed_topic' with the topic id
 * @return mixed False or {@link WP_Error} on failure, topic id on success
 */
function bbp_unspam_topic($topic_id = 0)
{
    // Get the topic
    if (!($topic = wp_get_single_post($topic_id, ARRAY_A))) {
        return $topic;
    }
    // Bail if already not spam
    if (bbp_get_spam_status_id() != $topic['post_status']) {
        return false;
    }
    // Execute pre unspam code
    do_action('bbp_unspam_topic', $topic_id);
    // Get pre spam status
    $topic_status = get_post_meta($topic_id, '_bbp_spam_meta_status', true);
    // Set post status to pre spam
    $topic['post_status'] = $topic_status;
    // Delete pre spam meta
    delete_post_meta($topic_id, '_bbp_spam_meta_status');
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Get pre-spam topic tags
    $terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
    // Topic had tags before it was spammed
    if (!empty($terms)) {
        // Set the tax_input of the topic
        $topic['tax_input'] = array(bbp_get_topic_tag_tax_id() => $terms);
        // Delete pre-spam topic tag meta
        delete_post_meta($topic_id, '_bbp_spam_topic_tags');
    }
    // Update the topic
    $topic_id = wp_insert_post($topic);
    // Execute post unspam code
    do_action('bbp_unspammed_topic', $topic_id);
    // Return topic_id
    return $topic_id;
}
Example #24
0
 function pingback_extensions_getPingbacks($args)
 {
     global $wpdb;
     $this->escape($args);
     $url = $args;
     $post_ID = url_to_postid($url);
     if (!$post_ID) {
         // We aren't sure that the resource is available and/or pingback enabled
         return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'));
     }
     $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     if (!$actual_post) {
         // No such post = resource not found
         return new IXR_Error(32, __('The specified target URL does not exist.'));
     }
     $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$wpdb->comments} WHERE comment_post_ID = {$post_ID}");
     if (!$comments) {
         return array();
     }
     $pingbacks = array();
     foreach ($comments as $comment) {
         if ('pingback' == $comment->comment_type) {
             $pingbacks[] = $comment->comment_author_url;
         }
     }
     return $pingbacks;
 }
Example #25
0
<?php

$post_id = get_the_ID();
$post = wp_get_single_post($post_id);
$event_date = get_field('event_date', $post_id);
$formatted_date = date('m/d/Y', strtotime($event_date));
$event_time = get_field('event_time', $post_id);
$formatted_time = !empty($event_time) ? ' @ ' . $event_time : '';
$event_venue = get_field('event_location_venue_name', $post_id);
$event_street_address = get_field('event_location_street_address', $post_id);
$event_city_state = get_field('event_location_city_state_zip', $post_id);
$cost = get_field('cost', $post_id);
$registry_link = get_field('registry_link', $post_id);
?>

<?php 
get_header();
?>
<div class="content">
  <!-- HERO SECTION -->
  <div id="eventspage-hero">
    <div class="wrap">
      <h1 class="text-center main">Events</h1>
    </div>
  </div>
  <!-- EVENTS -->
  <div id="events-breakdown" class="section">
    <div class="wrap">
      <main id="main" class="m-all t-2of3 d-3of4 cf" role="main">
        <div class="event-heading">
          <div class="m-all t-1of3 d-1of4 thumbnail-event">
Example #26
0
function initiation_received($table, $user)
{
    global $wpdb;
    $data = "";
    $resulteReceived = $wpdb->get_results("SELECT * FROM " . $table . " AS i  WHERE user_id =" . $user . " ORDER BY i.ID ASC");
    foreach ($resulteReceived as $val) {
        if ($val->year == 0) {
            $year = "Not sure";
        } else {
            $year = $val->year;
        }
        //Practice
        $argsPractice = array('post_type' => 'practic', 'orderby' => array('post_title' => 'ASC'), 'posts_per_page' => -1, 'post__in' => explode(',', $val->practice_id));
        $result = new WP_Query($argsPractice);
        $argEditPractice = array('post_type' => 'practic', 'orderby' => array('post_title' => 'ASC'), 'posts_per_page' => -1, 'post__not_in' => explode(",", $val->practice_id));
        $editPractice = new WP_Query($argEditPractice);
        //        $practiceID = wp_get_single_post($val->practice_id);
        //End practice
        //Teacher
        $teacher = wp_get_single_post($val->teacher_id);
        $argEditTeacher = array('post_type' => 'teacher', 'posts_per_page' => -1, 'post__not_in' => explode(",", $val->teacher_id));
        $editTeacher = new WP_Query($argEditTeacher);
        //End teacher
        $data .= "<tr>";
        $data .= "<td>";
        //$data.= "<p class='editHide'>" . $practiceID->post_title . "</p>";
        foreach ($result->posts as $key) {
            $data .= "<p class='editHide'>" . $key->post_title . "</p>";
        }
        $data .= "<p><select class='hide selectShow practiceEdit'>";
        //$data.= "<option value='" . $practiceID->ID . "' selected>" . $practiceID->post_title . "</option>";
        foreach ($result->posts as $practiceID) {
            $data .= "<option value='" . $practiceID->ID . "' selected>" . $practiceID->post_title . "</option>";
        }
        foreach ($editPractice->posts as $prac) {
            $data .= "<option value='" . $prac->ID . "'>" . $prac->post_title . "</option>";
        }
        $data .= "</select></p>";
        $data .= "</td>";
        $data .= "<td>";
        $data .= "<p class='editHide'>" . $teacher->post_title . "</p>";
        $data .= "<select class='selectShow hide teacherEdit'>";
        $data .= "<option value='" . $teacher->ID . "'>" . $teacher->post_title . "</option>";
        foreach ($editTeacher->posts as $practice) {
            $data .= "<option value='" . $practice->ID . "'>" . $practice->post_title . "</option>";
        }
        $data .= "<select>";
        $data .= "</td>";
        $data .= "<td>";
        $data .= "<p class='editHide'>" . $year . "</p>";
        $data .= "<select class='hide selectShow yearEdit'>";
        $data .= "<option value='" . $val->year . "'>" . $year . "</option>";
        if ($year == 0) {
        } else {
            $data .= "<option value='0'>Not sure</option>";
        }
        $number = range(2014, 1900);
        foreach ($number as $key) {
            $data .= "<option value=" . $key . ">" . $key . "</option>";
        }
        $data .= "</select>";
        $data .= "</td>";
        $data .= "<td>";
        $data .= "<span class='check selectEdit hide' data-id='" . $val->ID . "' data-user='******' >";
        $data .= do_shortcode("[tooltip text='Ok']<i class='fa fa-check-square-o'></i>[/tooltip]");
        $data .= "</span>";
        $data .= "<span class='uncheck selectEdit hide'>";
        $data .= do_shortcode("[tooltip text='Cancel']<i class='fa fa-sign-out'></i>[/tooltip]");
        $data .= "</span>";
        $data .= '<select class="action" data-id="' . $val->ID . '" data-user="******">
                        <option value="0">Action';
        //_e("Action", "Divi");
        $data .= '</option>
                        <option value="edit">Edit';
        //_e("Edit", "Divi");
        $data .= '</option>
                        <option value="del">Delete';
        //_e("Delete", "Divi");
        $data .= '</option>
                    </select>';
        $data .= "</td>";
        $data .= "</tr>";
    }
    return $data;
}
Example #27
0
 private function _import($type = 'post', $posts)
 {
     // get all the pages
     $pages = get_pages();
     $postIdList = array();
     foreach ($posts as $post) {
         $new = true;
         // title
         $title = wp_filter_kses($post['title']);
         // Getting the content of the page
         $html = str_get_html($post['content']);
         $body = $html->find('body');
         $bodyHtml = (string) $body[0]->innertext;
         $content = $bodyHtml;
         //get all the css files
         $cssList = $html->find('link[href]');
         //get all the js files
         $jsList = $html->find('script[src]');
         foreach ($cssList as $css) {
             //if it doesn't exist already, add it
             if (!in_array($this->_site['hostname'] . '/' . $css->attr['href'], $this->_css)) {
                 $this->_css[] = $this->_site['hostname'] . '/' . $css->attr['href'];
             }
         }
         foreach ($jsList as $js) {
             //if it doesn't exist already, add it
             if (!in_array($this->_site['hostname'] . '/' . $js->attr['src'], $this->_js)) {
                 $this->_js[] = $this->_site['hostname'] . '/' . $js->attr['src'];
             }
         }
         // Filter the post title...
         // Match the parent if required...
         $postParent = 0;
         if (isset($post['post_parent']) && $type == 'page') {
             $this->_output('[Parent: ');
             if ($parentPath = $this->_slug($post['post_parent_url'])) {
                 if ($parent = get_page_by_path($parentPath)) {
                     $postParent = $parent->ID;
                 }
             }
             $this->_output($postParent . '] ');
         }
         //If the page exists already don't add it again, don't do anything
         foreach ($pages as $pagg) {
             if ($pagg->post_title == $title) {
                 $new = false;
                 $postId = $pagg->ID;
                 break;
             }
         }
         if ($new) {
             // adding the page
             $postId = wp_insert_post(array('post_title' => $title, 'post_content' => $content, 'post_name' => $this->_slug($post['slug']), 'post_author' => 1, 'post_category' => array(1), 'post_type' => $type == 'page' ? 'page' : 'post', 'post_date' => $post['date'], 'post_status' => $post['status'] == 'y' ? 'publish' : 'draft', 'post_parent' => $postParent, 'comment_status' => $type == 'page' ? 'closed' : 'open', 'ping_status' => $type == 'page' ? 'closed' : 'open'));
             // Now we need to grab the images...
             $this->_output('[Images: ');
             if (!$this->_parseImages($postId, $content)) {
                 $this->_output('None');
             }
             $this->_output('] ');
             $this->_output('<a href="' . get_permalink($postId) . '" target="_blank">DONE</a>');
             $postIdList[$title] = $postId;
         }
         $this->_output('<br />');
     }
     // Maping the new post in order to change the links in the pages
     $guidList = array();
     foreach ($postIdList as $title => $postId) {
         $postLinked = wp_get_single_post($postId, OBJECT);
         $guidList[$postId] = $postLinked->guid;
     }
     // We change the url of all the links for the page which are going to the own website
     foreach ($postIdList as $title => $postId) {
         $post = wp_get_single_post($postId, OBJECT);
         $content = $post->post_content;
         $html = str_get_html($content);
         $linkList = $html->find('a[href]');
         foreach ($linkList as $link) {
             if (preg_match('/\\/*(.*)?\\.(php|html)/isU', $link->attr['href'], $links)) {
                 if (isset($postIdList[$links[1]])) {
                     $content = str_replace($link->attr['href'], $guidList[$postIdList[$links[1]]], $content);
                     wp_update_post(array('ID' => $postId, 'post_content' => $content));
                 }
             }
         }
     }
 }
Example #28
0
 function opendoor_displet_object_meta()
 {
     // construct meta tags creating OPN media asset object
     $publisherOptions = get_option('publisher_options');
     $postId = get_the_ID();
     $postInfo = wp_get_single_post($postId, ARRAY_A);
     if (!empty($publisherOptions["publisher_info"])) {
         // --- opn:site_name
         if (!empty($publisherOptions["publisher_info"]["site_name"])) {
             echo '<meta property="opn:site_name" content="' . $publisherOptions["publisher_info"]["site_name"] . '" />';
         }
         // --- opn:app_id
         if (!empty($publisherOptions["publisher_info"]["app_id"])) {
             echo '<meta property="opn:app_id" content="' . $publisherOptions["publisher_info"]["app_id"] . '" />';
         }
     }
     // --- opn:url
     $permaLink = get_permalink($postId);
     echo '<meta property="opn:url" content="' . $permaLink . '" />';
     // --- opn:type
     echo '<meta property="opn:type" content="article" />';
     // --- opn:title
     echo '<meta property="opn:title" content="' . get_the_title() . '" />';
     if (!empty($publisherOptions["content_targeting"]) && is_array($publisherOptions["content_targeting"])) {
         $myIndids = array();
         foreach ($publisherOptions["content_targeting"] as $index => $targetingInfo) {
             if (!empty($targetingInfo["uri"])) {
                 $pregReadyUrl = preg_quote($targetingInfo["uri"]);
                 $pregReadyUrl = preg_replace('/\\//', '\\/', $pregReadyUrl);
                 if (preg_match("/" . $pregReadyUrl . "/i", $permaLink)) {
                     $myIndids = array_merge($myIndids, $targetingInfo["indids"]);
                 }
             }
         }
         // --- opn:industries
         if (!empty($myIndids)) {
             echo '<meta property="opn:industries" content="' . implode(",", $myIndids) . '" />';
         }
     }
     // --- opn:image
     if (!empty($postInfo["post_content"])) {
         if (preg_match('/<img.+src *= *[\'"](?P<src>.+?)[\'"].*>/i', $postInfo["post_content"], $image)) {
             echo '<meta property="opn:image" content="' . $image["src"] . '" />';
         }
     }
     // --- opn:description
     //echo '<meta property="opn:description" content="'.get_post_meta($postId, 'description', false).'" />';
     // --- opn:keywords
     if (!empty($postInfo["tags_input"])) {
         echo '<meta property="opn:keywords" content="' . implode(",", $postInfo["tags_input"]) . '" />';
     }
     // --- opn:published
     // WARNING FOR REAL ESTATE  - anything with a publish tag will be considered a sharable media asset
     //  this is undesireable in the case of property listing pages as they will
     //  drown out original content from other sources like your blog.
     //
     //  So:
     //      ONLY include "opn:published" on blog pages you want publicized with fresh original content
     //  - OR -
     //      contact julia.smart@opner.com for details and solutions to determine which pages are indexed for sharing
     //
     if (!empty($postInfo["post_date_gmt"])) {
         // for blogs that only publish origional content the following line can be included to
         // automatically register new posts with OpenDoor Publisher Network.
         //echo '<meta property="opn:published" content="'.date($postInfo["post_date_gmt"]).'" />';
     }
     // --- opn:region
     //echo '<meta property="opn:region" content="''" />';
 }
Example #29
0
/**
 * Do trackbacks for a list of URLs.
 *
 * @since 1.0.0
 *
 * @param string $tb_list Comma separated list of URLs
 * @param int $post_id Post ID
 */
function trackback_url_list($tb_list, $post_id)
{
    if (!empty($tb_list)) {
        // get post data
        $postdata = wp_get_single_post($post_id, ARRAY_A);
        // import postdata as variables
        extract($postdata, EXTR_SKIP);
        // form an excerpt
        $excerpt = strip_tags($post_excerpt ? $post_excerpt : $post_content);
        if (strlen($excerpt) > 255) {
            $excerpt = substr($excerpt, 0, 252) . '...';
        }
        $trackback_urls = explode(',', $tb_list);
        foreach ((array) $trackback_urls as $tb_url) {
            $tb_url = trim($tb_url);
            trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
        }
    }
}
/**
 *
 * @global string $blog_in_blog_opts
 * @return array of posts
 */
function bib_get_posts()
{
    global $blog_in_blog_opts;
    $params = array();
    if ($blog_in_blog_opts['post_id'] == '') {
        // for multiposts
        if ($blog_in_blog_opts['tag_slug'] != '') {
            $params['tag_slug__in'] = explode(",", $blog_in_blog_opts['tag_slug']);
        }
        if ($blog_in_blog_opts['cat'] != '') {
            $params['category__in'] = explode(",", $blog_in_blog_opts['cat']);
        }
        if ($blog_in_blog_opts['cat_slug'] != '') {
            $params['category_name'] = $blog_in_blog_opts['cat_slug'];
        }
        if ($blog_in_blog_opts['custom_post_type'] != '') {
            $params['post_type'] = $blog_in_blog_opts['custom_post_type'];
        }
        if ($blog_in_blog_opts['author'] != '') {
            $params['author'] = $blog_in_blog_opts['author'];
        }
        if ($blog_in_blog_opts['author_name'] != '') {
            $params['author_name'] = $blog_in_blog_opts['author_name'];
        }
        if ($blog_in_blog_opts['custom_order_by'] != '') {
            $params['orderby'] = 'meta_value';
            $params['order'] = $blog_in_blog_opts['post_order'];
            $params['meta_key'] = $blog_in_blog_opts['custom_order_by'];
        } else {
            $params['orderby'] = $blog_in_blog_opts['order_by'];
            $params['order'] = $blog_in_blog_opts['post_order'];
        }
        //        if ($blog_in_blog_opts['taxonomy'] != ''){
        //
        //            if($blog_in_blog_opts['tax_operator'] != ''){
        //                $operator = $blog_in_blog_opts['tax_operator'];
        //            }
        //            else
        //            {
        //                $operator = 'IN';
        //            }
        //
        //            $params['tax_query'] = array(
        //                    'taxonomy' => $blog_in_blog_opts['taxonomy'],
        //                    'field' => $blog_in_blog_opts['tax_field'],
        //                    'terms' => explode(',',$blog_in_blog_opts['tax_terms']),
        //                    'operator' => $operator
        //                );
        //        }
        // apply whatever the case:
        $params['suppress_filters'] = false;
        // adjust the offsett
        if ($blog_in_blog_opts['hidefirst'] != '') {
            if ($blog_in_blog_opts['offset'] != '') {
                $params['offset'] = intval($blog_in_blog_opts['hidefirst']) + intval($blog_in_blog_opts['offset']);
            } else {
                $params['offset'] = intval($blog_in_blog_opts['hidefirst']);
            }
        } else {
            $params['offset'] = $blog_in_blog_opts['offset'];
        }
        $params['numberposts'] = $blog_in_blog_opts['num'];
        // get the posts.
        $postslist = get_posts($params);
    } else {
        // for single posts
        $postslist[0] = wp_get_single_post($blog_in_blog_opts['post_id']);
        $blog_in_blog_opts['pagination'] = 'off';
    }
    if ($blog_in_blog_opts['bib_debug']) {
        bib_write_debug(__FUNCTION__, "Params passed to get_posts()");
        bib_write_debug(__FUNCTION__, print_r($params, true));
        bib_write_debug(__FUNCTION__, "Response from get_posts()");
        bib_write_debug(__FUNCTION__, print_r($postslist, true));
    }
    return $postslist;
}