public function testPostsSelectionWithFilters() { // Create 2 posts and 2 entities $entity_1_id = wl_create_post('', 'entity0', 'An Entity', 'draft', 'entity'); $post_1_id = wl_create_post('', 'post1', 'A post', 'publish'); $post_2_id = wl_create_post('', 'post2', 'A post', 'publish'); // Insert relations wl_core_add_relation_instance($post_1_id, WL_WHAT_RELATION, $entity_1_id); wl_core_add_relation_instance($post_2_id, WL_WHAT_RELATION, $entity_1_id); // Set $_GET variable: this means we will perform data selection for $entity_1_id $_GET['post_id'] = $post_1_id; // Mock php://input $mock_http_raw_data = json_encode(array(wl_get_entity_uri($entity_1_id))); try { $this->_handleAjax('wordlift_related_posts', $mock_http_raw_data); } catch (WPAjaxDieContinueException $e) { } $response = json_decode($this->_last_response); $this->assertInternalType('array', $response); $this->assertCount(1, $response); $this->assertEquals('post', $response[0]->post_type); $this->assertEquals($post_2_id, $response[0]->ID); $this->assertEquals(get_edit_post_link($post_2_id, 'none'), $response[0]->link); $this->assertEquals(get_post_permalink($post_2_id), $response[0]->permalink); }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1; $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand'); if ($group = $instance['group']) { $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group)); } $terms = get_posts($termargs); if ($terms && count($terms)) { echo '<ul class="wpglossary widget-list">'; foreach ($terms as $term) { setup_postdata($term); $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>'; $desc = ''; $display = $instance['display']; if ($display && $display != 'title') { $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt()); $desc = '<br>' . $desc; } echo '<li>' . $title . $desc . '</li>'; } wp_reset_postdata(); echo '</ul>'; } else { echo '<em>' . __('No terms available', 'wp-glossary') . '</em>'; } echo $after_widget; }
function wordlift_ajax_related_posts($http_raw_data = null) { // Extract filtering conditions if (!isset($_GET["post_id"]) || !is_numeric($_GET["post_id"])) { wp_die('Post id missing or invalid!'); return; } $post_id = $_GET["post_id"]; // Get the current post $post = get_post($post_id); wl_write_log("Going to find posts related to current with post id: {$post_id} ..."); // Extract filtering conditions $filtering_entity_uris = null == $http_raw_data ? file_get_contents("php://input") : $http_raw_data; $filtering_entity_uris = json_decode($filtering_entity_uris); $filtering_entity_ids = wl_get_entity_post_ids_by_uris($filtering_entity_uris); $related_posts = array(); // If the current post is an antity // related posts to the current entity are returned if (Wordlift_Entity_Service::TYPE_NAME == $post->post_type) { $filtering_entity_ids = array($post_id); } if (!empty($filtering_entity_ids)) { $related_posts = wl_core_get_posts(array('get' => 'posts', 'related_to__in' => $filtering_entity_ids, 'post__not_in' => array($post_id), 'post_type' => 'post', 'post_status' => 'publish', 'as' => 'subject')); foreach ($related_posts as $post_obj) { $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post_obj->ID, 'thumbnail')); $post_obj->thumbnail = $thumbnail ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH; $post_obj->link = get_edit_post_link($post_obj->ID, 'none'); $post_obj->permalink = get_post_permalink($post_obj->ID); } } wl_core_send_json($related_posts); }
/** * Should we send the message over to email? * * @param array $data The data to be sent * @param array $settings The Integration settings * @param bool Is this a default message? * @return null */ function send_message($data, $settings, $default) { if (!isset($settings[$this->slug . '-enable'])) { return; } // Check if the to emails are set $to_emails = $settings[$this->slug . '-to-emails']; if (empty($to_emails)) { return; } $subject = ''; $message = ''; $headers = array(); // Check if this is a default message if ($default) { $subject = $data['text']; $message = $data['text']; } // Post Status if (isset($data['post_status']) && isset($data['post'])) { $subject = $data['post']->post_title . ' changed status to ' . $data['post_status']; $message = $data['post']->post_title . ' changed status to ' . $data['post_status'] . '.' . $this->new_line . $this->new_line . 'View: ' . get_post_permalink($data['post']->ID); } wp_mail(apply_filters('gnt_integration_' . $this->slug . '_to_emails', $to_emails), apply_filters('gnt_integration_' . $this->slug . '_subject', $subject), apply_filters('gnt_integration_' . $this->slug . '_message', $message), apply_filters('gnt_integration_' . $this->slug . '_headers', $headers)); }
public function show_ajax_form() { if (isset($_REQUEST['productid'])) { $dropdownargs = array('show_option_all' => false, 'show_option_none' => false, 'orderby' => 'id', 'order' => 'ASC', 'show_count' => 1, 'hide_empty' => 0, 'child_of' => 0, 'exclude' => '', 'echo' => 0, 'selected' => 0, 'hierarchical' => 1, 'name' => 'wcordersortupdateshelf', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'product_shelf', 'hide_if_empty' => false, 'option_none_value' => -1, 'value_field' => 'term_id'); $echo = ''; $product_name = '<a href="' . get_post_permalink($_REQUEST['productid']) . '" >' . get_the_title($_REQUEST['productid']) . '</a>'; $echo .= '<form method="post"> <table class="flat-table" cellspacing="3" >'; $echo .= '<tr>'; $echo .= '<th>Product Name : </th>'; $echo .= '<td>' . $product_name . '</td>'; $echo .= '</tr>'; $echo .= '<tr>'; $echo .= '<th>Shelf : </th>'; $echo .= '<td>' . wp_dropdown_categories($dropdownargs) . '</td>'; $echo .= '</tr>'; $echo .= '<tr>'; $echo .= '<td><input type="hidden" name="action" value="wcordersortforechangeshelf" /> </td>'; $echo .= '<td><input type="submit" class="myButton "value="Update Shelf"/> </td>'; $echo .= '</tr>'; $echo .= '</table> </form>'; $echo .= '<style>'; $echo .= 'table { width: 100%; } th { background: #eee; color: black; font-weight: bold; } td, th { padding: 6px; border: 1px solid #ccc; text-align: left; }'; $echo .= ".myButton {\tbackground:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #77b55a), color-stop(1, #72b352)); background:-moz-linear-gradient(top, #77b55a 5%, #72b352 100%); \tbackground:-webkit-linear-gradient(top, #77b55a 5%, #72b352 100%); \tbackground:-o-linear-gradient(top, #77b55a 5%, #72b352 100%); background:-ms-linear-gradient(top, #77b55a 5%, #72b352 100%); background:linear-gradient(to bottom, #77b55a 5%, #72b352 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#77b55a', endColorstr='#72b352',GradientType=0); background-color:#77b55a; -moz-border-radius:4px; \t-webkit-border-radius:4px; \tborder-radius:4px; \tborder:1px solid #4b8f29; display:inline-block; cursor:pointer; color:#ffffff; font-family:Arial; font-size:15px; font-weight:bold; padding:6px 12px;\ttext-decoration:none;\ttext-shadow:0px 1px 0px #5b8a3c;} .myButton:hover { background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #72b352), color-stop(1, #77b55a)); \tbackground:-moz-linear-gradient(top, #72b352 5%, #77b55a 100%); \tbackground:-webkit-linear-gradient(top, #72b352 5%, #77b55a 100%); \tbackground:-o-linear-gradient(top, #72b352 5%, #77b55a 100%); \tbackground:-ms-linear-gradient(top, #72b352 5%, #77b55a 100%); \tbackground:linear-gradient(to bottom, #72b352 5%, #77b55a 100%); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#72b352', endColorstr='#77b55a',GradientType=0); \tbackground-color:#72b352; } .myButton:active { \tposition:relative; \ttop:1px; }"; $echo .= '</style>'; echo $echo; } wp_die(); }
public function test_google_utm_link() { $link = get_post_permalink($this->_post_id); $name = 'sharedate_0_' . $this->_post_id . '_tw'; $unique_link = ppp_generate_google_utm_link($link, $this->_post_id, $name); $this->assertEquals('http://example.org/?post_type=post&p=' . $this->_post_id . '&utm_source=Twitter&utm_medium=social&utm_term=test-post&utm_content=0&utm_campaign=PostPromoterPro', $unique_link); }
/** * launch a landing page */ function test_landing_page_read() { return; /* includes */ include_once LANDINGPAGES_PATH . 'classes/class.statistics.php'; $permalink = get_post_permalink($this->lp_id, false); echo $permalink . "\r\n"; $permalink = 'http://local.wordpress.dev/go/ab-testing-landing-page-example-104/?lp-variation-id=1'; $permalink = 'http://local.wordpress.dev/'; print_r(inbound_remote_get($permalink)); /* sleep(5); $response = inbound_remote_get( $permalink ); sleep(5); $response = inbound_remote_get( $permalink ); sleep(5); $response = inbound_remote_get( $permalink ); sleep(5); $response = inbound_remote_get( add_query_arg( array('lp-variation-id'=> 0 ) , $permalink ) ); sleep(5); $response = inbound_remote_get( add_query_arg( array('lp-variation-id'=> 1 ) , $permalink ) ); sleep(5); */ $stats = Landing_Pages_Statistics::read_statistics($this->lp_id); print_r($stats); $this->assertEquals($stats['impressions'][0], 3); $this->assertEquals($stats['conversions'][0], 0); $this->assertEquals($stats['impressions'][1], 3); $this->assertEquals($stats['conversions'][1], 0); }
function cdm_logout_url() { global $wp_query; $post_id = $wp_query->post->ID; $logout = wp_logout_url(get_post_permalink($post_id)); $logout = apply_filters('spcdm/links/logout', $logout); return $logout; }
public static function em_wp_localize_script($vars) { if (get_option('dbem_multiple_bookings_redirect')) { $vars['mb_redirect'] = get_post_permalink(get_option('dbem_multiple_bookings_checkout_page')); } $vars['mb_empty_cart'] = get_option('dbem_multiple_bookings_feedback_empty_cart'); return $vars; }
public function setupFromPost() { $this->id = $this->post->ID; $this->title = $this->post->post_title; $this->date = $this->post->post_date; $this->postUrl = get_post_permalink($this->id); $this->snippet = get_post_meta($this->id, 'snippet', true); }
/** * Start rendering an item element * * This overrides the parent method. * * @param string $output Passed by reference. Used to append additional content. * @param object $page Page data object. * @param int $depth Depth of page. Used for padding. * @param array $args * @param int $current_page Page ID. */ function start_el(&$output, $page, $depth, $args, $current_page) { // need the menu item classes $classes[] = 'menu-item'; $classes[] = 'menu-item-type-post_type'; $classes[] = 'menu-item-object-page'; // our custom output $output .= infinity_base_superfish_list_item(array('id' => $page->ID, 'title' => apply_filters('the_title', $page->post_title, $page->ID), 'close_item' => false, 'li_classes' => $classes, 'a_title' => $page->post_title, 'a_href' => get_post_permalink($page->ID), 'a_target' => isset($args['target']) ? $args['target'] : null, 'a_rel' => isset($args['rel']) ? $args['rel'] : null, 'a_open' => isset($args['link_before']) ? $args['link_before'] : null, 'a_close' => isset($args['link_after']) ? $args['link_after'] : null), false); }
/** * Change redirect link when comment for answer finished * @param string $location Old redirect link * @param object $comment Comment Object * @return string New redirect link */ public function hook_redirect_comment_for_answer($location, $comment) { if ('dwqa-answer' == get_post_type($comment->comment_post_ID)) { $question = get_post_meta($comment->comment_post_ID, '_question', true); if ($question) { return get_post_permalink($question) . '#' . 'answer-' . $comment->comment_post_ID . '&comment=' . $comment->comment_ID; } } return $location; }
/** * AJAX handler for saving the post as draft or published. * * @since 4.2.0 * @access public */ public function save_post() { if (empty($_POST['post_ID']) || !($post_id = (int) $_POST['post_ID'])) { wp_send_json_error(array('errorMessage' => __('Missing post ID.'))); } if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'update-post_' . $post_id) || !current_user_can('edit_post', $post_id)) { wp_send_json_error(array('errorMessage' => __('Invalid post.'))); } $post = array('ID' => $post_id, 'post_title' => !empty($_POST['post_title']) ? sanitize_text_field(trim($_POST['post_title'])) : '', 'post_content' => !empty($_POST['post_content']) ? trim($_POST['post_content']) : '', 'post_type' => 'post', 'post_status' => 'draft', 'post_format' => !empty($_POST['post_format']) ? sanitize_text_field($_POST['post_format']) : '', 'tax_input' => !empty($_POST['tax_input']) ? $_POST['tax_input'] : array(), 'post_category' => !empty($_POST['post_category']) ? $_POST['post_category'] : array()); if (!empty($_POST['post_status']) && 'publish' === $_POST['post_status']) { if (current_user_can('publish_posts')) { $post['post_status'] = 'publish'; } else { $post['post_status'] = 'pending'; } } $post['post_content'] = $this->side_load_images($post_id, $post['post_content']); $updated = wp_update_post($post, true); if (is_wp_error($updated)) { wp_send_json_error(array('errorMessage' => $updated->get_error_message())); } else { if (isset($post['post_format'])) { if (current_theme_supports('post-formats', $post['post_format'])) { set_post_format($post_id, $post['post_format']); } elseif ($post['post_format']) { set_post_format($post_id, false); } } $forceRedirect = false; if ('publish' === get_post_status($post_id)) { $redirect = get_post_permalink($post_id); } elseif (isset($_POST['pt-force-redirect']) && $_POST['pt-force-redirect'] === 'true') { $forceRedirect = true; $redirect = get_edit_post_link($post_id, 'js'); } else { $redirect = false; } /** * Filter the URL to redirect to when Press This saves. * * @since 4.2.0 * * @param string $url Redirect URL. If `$status` is 'publish', this will be the post permalink. * Otherwise, the default is false resulting in no redirect. * @param int $post_id Post ID. * @param string $status Post status. */ $redirect = apply_filters('press_this_save_redirect', $redirect, $post_id, $post['post_status']); if ($redirect) { wp_send_json_success(array('redirect' => $redirect, 'force' => $forceRedirect)); } else { wp_send_json_success(array('postSaved' => true)); } } }
/** * Output the metabox */ public static function output($post) { $feeds = new SP_Feeds(); $calendar_feeds = $feeds->calendar; ?> <div> <?php foreach ($calendar_feeds as $slug => $formats) { ?> <?php $link = add_query_arg('feed', 'sp-' . $slug, untrailingslashit(get_post_permalink($post))); ?> <?php foreach ($formats as $format) { ?> <?php $protocol = sp_array_value($format, 'protocol'); if ($protocol) { $feed = str_replace(array('http:', 'https:'), 'webcal:', $link); } else { $feed = $link; } $prefix = sp_array_value($format, 'prefix'); if ($prefix) { $feed = $prefix . urlencode($feed); } ?> <p> <strong><?php echo sp_array_value($format, 'name'); ?> </strong> <a class="sp-link" href="<?php echo $feed; ?> " target="_blank" title="<?php _e('Link', 'sportspress'); ?> "></a> </p> <p> <input type="text" value="<?php echo $feed; ?> " readonly="readonly" class="code widefat"> </p> <?php } ?> <?php } ?> </div> <?php }
function widget($args, $instance) { global $tc; if (tc_current_url() !== $cart_url || $show_widget_on_cart_page) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('tc_cart_widget_title', $instance['title']); $events_count = empty($instance['events_count']) ? 10 : apply_filters('tc_events_count_widget_value', $instance['events_count']); if (!empty($title)) { echo $before_title . $title . $after_title; } //event_date_time $tc_events_args = array('posts_per_page' => (int) $events_count, 'meta_query' => array(array('key' => 'event_date_time', 'value' => date('Y-m-d h:i'), 'type' => 'DATETIME', 'compare' => '>='), 'orderby' => 'event_date_time'), 'order' => 'ASC', 'orderby' => 'meta_value', 'post_type' => 'tc_events', 'post_status' => 'publish'); $tc_events = get_posts($tc_events_args); ?> <?php // Cart Contents if (!empty($tc_events)) { do_action('tc_upcoming_events_before_ul', $tc_events); ?> <ul class='tc_upcoming_events_ul'> <?php foreach ($tc_events as $tc_event) { $event_content = '<li id="tc_upcoming_event_' . $tc_event->ID . '"> <a href="' . get_post_permalink($tc_event->ID) . '">' . get_the_title($tc_event->ID) . '</a> <span class="tc_event_data_widget">' . do_shortcode('[tc_event_date id="' . $tc_event->ID . '"]') . '</span> </li>'; echo apply_filters('tc_upcoming_events_widget_event_content', $event_content, $tc_event->ID); } ?> </ul><!--tc_cart_ul--> <?php do_action('tc_upcoming_events_after_ul', $tc_events); } else { do_action('tc_upcoming_events_before_empty'); ?> <span class='tc_empty_upcoming_events'><?php _e('There are no upcoming events at this time.', 'tc'); ?> </span> <?php do_action('tc_upcoming_events_after_empty'); } ?> <div class='tc-clearfix'></div> <?php echo $after_widget; } }
public function setupFromPost() { $this->id = $this->post->ID; $this->title = $this->post->post_title; $this->date = $this->post->post_date; $this->postUrl = get_post_permalink($this->id); $this->url = trim($this->post->post_excerpt); $this->thumbId = get_post_thumbnail_id($this->id); $imageURLParts = wp_get_attachment_image_src(get_post_thumbnail_id($this->id), 'single-post-thumbnail'); if ($imageURLParts) { $this->imageURL = $imageURLParts[0]; } }
public function setupFromPost() { $this->id = $this->post->ID; $this->title = $this->post->post_title; $this->date = $this->post->post_date; $this->url = get_post_permalink($this->id); $this->thumbId = get_post_thumbnail_id($this->id); $this->content = apply_filters('the_content', $this->post->post_content); $imageURLParts = wp_get_attachment_image_src(get_post_thumbnail_id($this->id), 'single-post-thumbnail'); if ($imageURLParts) { $this->imageURL = $imageURLParts[0]; } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = $instance['title']; $num_comments = $instance['number_comments']; $args = array('number' => $num_comments, 'status' => 'approve'); $comments = get_comments($args); if (count($comments) == 0) { ?> <!-- Note, MBU: Recent Comments Widget not shown. No comments to display --> <?php } else { /* Before widget (defined by themes). */ echo $before_widget; ?> <div id="recent-comments" > <h2><?php echo $title; ?> </h2> <ul> <?php foreach ($comments as $comment) { $commented_post = get_post($comment->comment_post_ID); $commented_post_link = convert_chars(get_post_permalink($comment->comment_post_ID)) . '#comment-' . $comment->comment_ID; ?> <li> <a href="<?php echo $commented_post_link; ?> " title="<?php printf(_x('By %1$s on %2$s.', ' By [comment author] on [post title]', TEMPLATE_DOMAIN), $comment->comment_author, $commented_post->post_title); ?> " ><?php echo $comment->comment_content; ?> </a> </li> <?php } ?> </ul> </div> <?php /* After widget (defined by themes). */ echo $after_widget; } }
/** * Parse Redirect * * @todo Delete in next release * @param mixed */ protected function parseRedirect($redirect) { if (filter_var($redirect, FILTER_VALIDATE_URL)) { wp_redirect($redirect); exit; } elseif (is_int($redirect)) { wp_redirect(get_post_permalink($redirect)); exit; } elseif (is_object($redirect) && isset($redirect->userFunc)) { $func = trim($redirect->userFunc); if (is_string($func) && is_callable($func)) { call_user_func($func); } } }
function update_post($content) { $_number_roman = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); $_number_tibet = array('༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩'); $title = get_the_title(); $id = get_the_ID(); $link = get_post_permalink(); $time = get_the_time(); $new_time = str_replace($_number_roman, $_number_tibet, $time); $_comments = get_comments_number(); $_comments = str_replace($_number_roman, $_number_tibet, $_comments); $updated_content = str_replace($_number_roman, $_number_tibet, $content); //return $updated_content. $_comments; return '<a href="' . $link . '"><b>' . $title . '</b></a>' . $updated_content . '<br />' . $new_time . ' | ' . $_comments . 'comments'; }
function process_form() { if (isset($_POST['flg_form'])) { global $post; $response = array(); $post_url = $post->post_type == "post" || $post->post_type == "page" ? get_permalink($_POST['flg_form_post_id']) : get_post_permalink($_POST['flg_form_post_id']); if (!wp_verify_nonce($_POST['flg_form_nonce'], 'flg_form_noncerator_' . $_POST['flg_form_post_id'])) { return; } if ($_SERVER['HTTP_REFERER'] != $post_url) { return; } if (isset($_POST['flg_form']['user_middlename']) && $_POST['flg_form']['user_middlename'] != "") { $response['success'] = true; $_SESSION['flg_response'] = serialize($response); return; } $form_fields = !empty($_SESSION['flg_fields']) ? unserialize($_SESSION['flg_fields']) : $this->get_form_fields[$_POST['form_type']]; unset($form_fields[array_search('middle_name', $form_fields)]); $main_fields = $this->get_fields(); $response['flg_form_errors'] = array(); $response['success'] = true; foreach ($form_fields as $field) { $field_info = $main_fields[$field]; if ($field_info['required'] && $_POST['flg_form'][$field_info['name']] == '') { $response['success'] = false; $response['flg_form_errors']['required_error'] = "Please fill in all required fields"; } if ($field == "email" && !$this->valid_email($_POST['flg_form']['user_email'])) { $resonse['success'] = false; $response['flg_form_errors']['email_eror'] = "Invalid email"; } if ($field_info['confirm'] && $_POST['flg_form'][$field_info['name']] != $_POST['flg_form'][$field_info['name']]['confirm']) { $response['success'] = false; $response['flg_form_errors']['confirm_error'] = $field . " entry and confirmation don't match"; } $_SESSION['flg_form'][$field_info['name']] = $_POST['flg_form'][$field_info['name']]; } if ($response['success'] == true) { $response['success'] = intval($this->process_data()) > 0; } if (defined('DOING_AJAX') && DOING_AJAX) { echo json_encode($response); } else { $_SESSION['flg_response'] = serialize($response); } } }
/** * Prints the box content. * * @param WP_Post $post The object for the current post/page. */ function clink_stats_info_callback($post) { $post_id = $post->ID; $clicks = get_post_meta($post_id, 'clink_clicks', true); if (!$clicks) { $clicks = '0'; } echo '<p>'; echo '<h4>' . __('Permalink', 'aryan-themes') . '</h4>'; echo '<input class="clink-permalink" type="url" readonly="" value="' . get_post_permalink($post_id) . '">'; echo '</p>'; echo '<p>'; echo '<h4>' . __('Clicks', 'aryan-themes') . '</h4>'; echo '<code>' . $clicks . '</code>'; echo '</p>'; }
/** * Inserts a comment in the database for a given post. * * @param int $post_id * @param string $content * * @return false|int Either the inserted comment `comment_id` or `false` on failure. */ public function add_vote_for_post($post_id, $content) { if (empty(get_post($post_id))) { return false; } if (empty($content)) { return false; } $comments = $this->get_post_comments($post_id); $comment_data = array('comment_post_ID' => $post_id, 'comment_author' => 'Anonymous', 'comment_author_url' => get_post_permalink($post_id), 'comment_author_email' => 'idlikethis@' . home_url(), 'comment_content' => count($comments) . ' - ' . $content, 'comment_type' => 'idlikethis', 'user_id' => get_current_user_id(), 'comment_approved' => 1); try { return wp_new_comment($comment_data); } catch (WPDieException $e) { return false; } }
function meeting_get_summary($post_id) { $query_args = array('connected_type' => 'meeting_to_summary', 'connected_items' => intval($post_id), 'nopaging' => true); $summaries = get_posts($query_args); $content = ''; if (count($summaries) > 0) { foreach ($summaries as $post) { $post_type_obj = get_post_type_object(get_post_type($post->ID)); $post_type_name = $post_type_obj ? $post_type_obj->labels->singular_name : ''; $content .= '<li class="summary-link"><a href="' . get_post_permalink($post->ID) . '">'; $content .= $post_type_name ? $post_type_name : $post->post_title; $content .= '</a></li>'; } } // Filter added to allow content be overriden return apply_filters('meeting_get_summary_content', $content, $post_id); }
public function widget($args, $instance) { extract($args); $posts = get_posts(array('posts_per_page' => $instance['number'], 'post_type' => 'services', 'meta_key' => 'show_on_homepage', 'meta_value' => 1)); if ($posts) { $list_services = '<div class="col-sm-3 col-xs-8 second-table"> <div class="second-table-content"> <ul>'; foreach ($posts as $post) { $list_services .= '<li><div class="li-style">■</div> <a href="' . get_post_permalink($post->ID) . '">' . $post->post_title . '</a></li>'; } $list_services .= '</ul></div>'; if ($instance['link'] != '') { $list_services .= '<div class="second-table-button"><a href="' . $instance['link'] . '" target="' . $instance['link_target'] . '" class="btn cya-btn">DETAIL ></a></div>'; } $list_services .= '</div>'; echo $list_services; } }
/** * Prepares the email subjects and messages for sending by replacing placeholders with suitable values. * * @var $emails array The array in which we want to replace placeholders with values. * @var $post_data array User submitted data. * @return $emails array A modified array with all the placeholders replaced with values. **/ public function prepare_emails($emails, $post_data, $post_type) { $values['post_title'] = wp_strip_all_tags($post_data['title']); $values['post_permalink'] = get_post_permalink($post_data['post_id']); $author_id = get_post_field('post_author', $post_data['post_id']); $values['author_name'] = get_the_author_meta('display_name', $author_id); $values['site_name'] = get_bloginfo('name'); $values['site_url'] = get_bloginfo('url'); $admin_info = get_userdata(1); $values['admin_name'] = $admin_info->display_name; $values['edit_link'] = sprintf(admin_url('edit.php?post_type=%s'), $post_type); $values['copyscape_status'] = get_post_meta($post_data['post_id'], WPFEPP_CopyScape::$meta_key, true); foreach ($emails as $key => $email_part) { $emails[$key] = $this->fill_placeholders($email_part, $values); } return $emails; }
public function widget($args, $instance) { $title = $instance["title"]; $slug = $instance["slug"]; query_posts(array('category_name' => $slug, 'posts_per_page' => -1)); echo '<div id="nav_menu-3" class="fwidget et_pb_widget widget_nav_menu">'; echo '<h4 class="title">' . $title . '</h4>'; echo '<div class="menu-footer-links-container"><ul id="menu-footer-links" class="menu">'; while (have_posts()) { the_post(); echo '<li class="menu-item menu-item-type-post_type menu-item-object-page">'; echo '<a href="' . get_post_permalink() . '">' . get_the_title() . '</a>'; echo '</li>'; } echo '</ul></div></div>'; wp_reset_query(); }
function list_subpages($atts) { $attributes = (object) shortcode_atts(array('link' => 'Read more', 'tilebox' => false), $atts); global $post; $subpages = get_pages(array('parent' => get_the_ID(), 'sort_column' => 'menu_order')); if (!empty($subpages)) { $output = ''; $tiles = 0; foreach ($subpages as $page) { $permalink = get_post_permalink($page->ID); if (!$attributes->tilebox) { $output = $output . sprintf("<h2><a href='%s'>%s</a></h2>", $permalink, $page->post_title); if (get_option('show_byline_on_posts')) { $output = $output . sprintf("<div class='author-info'><p class='author-desc'><small>%s</small></p></div>", get_the_author_meta('display_name', $page->post_author)); } $output = $output . sprintf('<p>%s</p>', $page->post_excerpt); if (!empty($attributes->link)) { $output = $output . sprintf("<a class='uw-btn btn-sm' href='%s'>%s</a>", $permalink, $attributes->link); } } else { if ($tiles == 0) { $output = $output . "<div class='box-outer'><div class='box two'>"; } $output = $output . "<div class='tile'>"; $output = $output . sprintf("<div>%s</div>", get_the_post_thumbnail($page->ID, 'half')); $output = $output . sprintf("<h3><a href='%s'>%s</a></h3>", $permalink, $page->post_title); if (get_option('show_byline_on_posts')) { $output = $output . sprintf("<div class='author-info'><p class='author-desc'><small>%s</small></p></div>", get_the_author_meta('display_name', $page->post_author)); } $output = $output . sprintf('<p>%s</p>', $page->post_excerpt); $output = $output . "</div>"; $tiles = $tiles + 1; if ($tiles == 2) { $output = $output . "</div></div>"; $tiles = 0; } } } if ($tiles == 1) { //we've been incrementing tiles, so tilebox is active, but we are missing a blank tile and closing tags $output = $output . "<div class='tile empty'></div></div></div>"; } } return $output; }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $comment_phrase = $instance['comment_phrase']; $comment_id = $instance['comment_id']; $comment = get_comment($comment_id); if (!$comment) { ?> <!-- Note, MBU: Featured Comment Widget not shown. No comment to display --> <?php } else { $author = '<cite>' . $comment->comment_author . '</cite>'; $artwork_post = get_post($comment->comment_post_ID); $post_link = '<a href="' . get_post_permalink($comment->comment_post_ID) . '" title="' . $artwork_post->post_title . '" >' . $artwork_post->post_title . '</a>'; $comment_phrase_replaced = str_replace('#author#', $author, $comment_phrase); $comment_phrase_replaced = str_replace('#title#', $post_link, $comment_phrase_replaced); /* Before widget (defined by themes). */ echo $before_widget; ?> <div id="featured-comment" > <blockquote> <?php echo $comment->comment_content; ?> </blockquote> <div class="grid_2"> <?php echo mbudm_get_post_image($comment->comment_post_ID, 'artwork-2', true, ''); ?> </div> <p> <?php echo $comment_phrase_replaced; ?> </p> </div> <?php /* After widget (defined by themes). */ echo $after_widget; } }
/** * Should we send the message over to slack? * * @param array $data The data to be sent * @param array $settings The Integration settings * @param bool Is this a default message? * @return null */ function check_send_message($data, $settings, $default) { if (!isset($settings[$this->slug . '-enable'])) { return; } // Check if webhook is set $webhook = $settings[$this->slug . '-webhook']; if (empty($webhook)) { return; } // Check if this is a default message if ($default) { $this->send_message($webhook, array('text' => $data['text'])); return; } // Post Status if (isset($data['post_status']) && isset($data['post'])) { $this->send_message($webhook, array('text' => '<' . get_post_permalink($data['post']->ID) . '|' . $data['post']->post_title . '> changed status to ' . $data['post_status'] . '.')); return; } }