function work_complete($job_id, $update = false)
 {
     global $iclTranslationManagement, $sitepress, $wpdb;
     $job = $iclTranslationManagement->get_translation_job($job_id);
     if ($job->manager_id == $job->translator_id) {
         return;
     }
     $manager = new WP_User($job->manager_id);
     $translator = new WP_User($job->translator_id);
     // get current user admin language
     $user_language = $sitepress->get_user_admin_language($manager->ID);
     if (empty($user_language)) {
         $user_language = $sitepress->get_admin_language();
     }
     $lang_from = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}icl_languages_translations WHERE language_code='%s' AND display_language_code='%s'", $job->source_language_code, $user_language));
     $lang_to = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}icl_languages_translations WHERE language_code='%s' AND display_language_code='%s'", $job->language_code, $user_language));
     $tj_url = get_option('siteurl') . '/wp-admin/admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/translation-management.php&sm=jobs';
     $doc_url = get_edit_post_link($job->original_doc_id);
     if ($iclTranslationManagement->settings['notification']['completed'] == ICL_TM_NOTIFICATION_IMMEDIATELY) {
         $mail['to'] = $manager->user_email;
         if ($update) {
             $mail['subject'] = sprintf(__('Translator has updated translation job for %s', 'sitepress'), get_bloginfo('name'));
             $mail['body'] = sprintf(__("Translator (%s) has updated translation of job \"%s\" for %s to %s.\n%s\n\nView translation jobs: %s", 'sitepress'), $translator->display_name, $job->original_doc_title, $lang_from, $lang_to, $doc_url, $tj_url);
         } else {
             $mail['subject'] = sprintf(__('Translator has completed translation job for %s', 'sitepress'), get_bloginfo('name'));
             $mail['body'] = sprintf(__("Translator (%s) has completed translation of job \"%s\" for %s to %s.\n%s\n\nView translation jobs: %s", 'sitepress'), $translator->display_name, $job->original_doc_title, $lang_from, $lang_to, $doc_url, $tj_url);
         }
         $mail['type'] = 'admin';
         $this->send_mail($mail);
     }
 }
コード例 #2
0
    /**
     * Render Meta Box content.
     */
    public function answers_meta_box_content()
    {
        $ans_args = array('post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => get_the_ID(), 'showposts' => 10, 'orderby' => 'date', 'order' => 'DESC');
        $ans_args = apply_filters('ap_meta_box_answers_query_args', $ans_args);
        $answers = get_posts($ans_args);
        if (!empty($answers)) {
            foreach ($answers as $ans) {
                ?>

			<div class="answer clearfix">
				<div class="author">
					<span><?php 
                echo get_avatar($ans->post_author, 30);
                ?>
</span>
					<strong><?php 
                echo ap_user_display_name($ans->post_author);
                ?>
</strong>
				</div>
				<div class="answer-content">
					<div class="submitted-on">
						<?php 
                printf(__('%sAnswered about %s ago%s', 'ap'), '<span class="when">', '</span>', ap_human_time(get_the_time('U', $ans)));
                ?>

					</div>
					<p><?php 
                echo $ans->post_content;
                ?>
</p>
					<div class="row-actions">
						<span><a href="<?php 
                echo get_edit_post_link($ans->ID);
                ?>
"><?php 
                _e('Edit', 'ap');
                ?>
</a></span>
						<span> | <a href="#"><?php 
                _e('Hide', 'ap');
                ?>
</a></span>
						<span class="delete vim-d vim-destructive"> | <a href="<?php 
                echo get_delete_post_link($ans->ID);
                ?>
"><?php 
                _e('Trash', 'ap');
                ?>
</a></span>
					</div>
				</div>
			</div>
		<?php 
            }
        } else {
            _e('No answers yet', 'ap');
        }
        wp_reset_postdata();
    }
コード例 #3
0
ファイル: Fields.php プロジェクト: daanbakker1995/vanteun
 /**
  * Acquirrer field input
  *
  * @param string $field_content
  * @param string $field
  * @param string $value
  * @param string $lead_id
  * @param string $form_id
  */
 public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
 {
     $type = RGFormsModel::get_input_type($field);
     if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
         $id = $field['id'];
         $field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
         $size = rgar($field, 'size');
         $class = $size . $class_suffix;
         $css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
         $tab_index = GFCommon::get_tabindex();
         $disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
         $html = '';
         $feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
         /**
          * Developing warning:
          * Don't use single quotes in the HTML you output, it is buggy in combination with SACK
          */
         if (IS_ADMIN) {
             if (null === $feed) {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
             } else {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
             }
         }
         $html_input = '';
         $html_error = '';
         if (null !== $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway) {
                 $issuer_field = $gateway->get_issuer_field();
                 $error = $gateway->get_error();
                 if (is_wp_error($error)) {
                     $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
                     $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
                 } elseif ($issuer_field) {
                     $choices = $issuer_field['choices'];
                     $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
                     // Double quotes are not working, se we replace them with an single quote
                     $options = str_replace('"', '\'', $options);
                     $html_input = '';
                     $html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
                     $html_input .= sprintf('%s', $options);
                     $html_input .= sprintf('</select>');
                 }
             }
         }
         if ($html_error) {
             $html .= sprintf("<div class='gfield_description validation_message'>");
             $html .= sprintf('%s', $html_error);
             $html .= sprintf('</div>');
         } else {
             $html .= sprintf("<div class='ginput_container ginput_ideal'>");
             $html .= sprintf('%s', $html_input);
             $html .= sprintf('</div>');
         }
         $field_content = $html;
     }
     return $field_content;
 }
コード例 #4
0
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);
}
コード例 #5
0
function testimonial_rotator_add_columns($column, $post_id)
{
    $edit_link = get_edit_post_link($post_id);
    $rotator_ids = testimonial_rotator_break_piped_string(get_post_meta($post_id, "_rotator_id", true));
    $rotator_title_array = array();
    foreach ($rotator_ids as $rotator_id) {
        $rotator_title_array[] = "<a href='post.php?action=edit&post=" . $rotator_id . "'>" . get_the_title($rotator_id) . "</a>";
    }
    $this_testimonial = get_post($post_id);
    if ($column == 'ID') {
        echo implode(", ", $rotator_title_array);
    }
    if ($column == 'image') {
        echo '<a href="' . $edit_link . '">' . get_the_post_thumbnail($post->ID, array(50, 50), array('title' => trim(strip_tags($post->post_title)))) . '</a>';
    }
    if ($column == 'order') {
        echo '<a href="' . $edit_link . '">' . $this_testimonial->menu_order . '</a>';
    }
    if ($column == 'rating') {
        echo get_post_meta($post_id, "_rating", true);
    }
    if ($column == 'shortcode') {
        echo '<b>' . __('Display as Single', 'testimonial-rotator') . '</b><br />';
        echo '[testimonial_single id="' . $post_id . '"]';
    }
}
コード例 #6
0
function fnt_dashboard_widget()
{
    $clientid = '9f690b3117f0c43767528e2b60bc70ce';
    $args = array('posts_per_page' => -1, 'offset' => 0, 'post_status' => array('publish', 'draft'), 'post_type' => 'tracks');
    $errors = 0;
    $query = new WP_Query($args);
    while ($query->have_posts()) {
        $query->the_post();
        $id = get_the_ID();
        $track_url = get_post_meta($id, 'track_url', true);
        $errored = 0;
        if (get_post_status() == 'draft') {
            $errored = 1;
        } else {
            $soundcloud_url = 'https://api.soundcloud.com/resolve?url=' . $track_url . '&format=json&consumer_key=' . $clientid;
            $track_json = file_get_contents($soundcloud_url);
            $track = json_decode($track_json);
            if ($track == null || isset($track->errors) && isset($track->errors[0]) && $track->errors[0]->error_message == '404 - Not Found' || $track->errors[0]->error_message == 'HTTP Error: 403') {
                $errored = 1;
                $update = array('ID' => $id, 'post_status' => 'draft');
                wp_update_post($update);
            }
        }
        if ($errored > 0) {
            echo '<span style="color:red;">SC Track is private & won\'t play: </span>&nbsp;' . '<a href="' . get_edit_post_link() . '" target="_blank">' . get_the_title() . '</a><br/>';
            $errors++;
        }
    }
    if ($errors > 0) {
        echo '<br/><em>These ' . $errors . ' posts are all drafts, but should probably be fixed or removed.</em>';
    } else {
        echo 'There are no broken tracks! That is SHOCKING :)';
    }
}
コード例 #7
0
 /**
  * Registering a post type
  *
  * @param string $type slug of the type
  * @param string $singular singular name
  * @param string $plural plural name
  * @param array $config can override the defaults of this function (array_merge)
  */
 public static function registerPostType($type, $singular, $plural, $config = array())
 {
     $labels = array('name' => $plural, 'singular_name' => $singular, 'add_new' => 'Erstellen', 'add_new_item' => $singular . ' erfassen', 'edit_item' => 'Bearbeite ' . $singular, 'new_item' => 'Neues ' . $singular, 'view_item' => $singular . ' ansehen', 'search_items' => $singular . ' suchen', 'not_found' => 'Keine ' . $plural . ' gefunden', 'not_found_in_trash' => 'Keine ' . $plural . ' im Papierkorb gefunden', 'parent_item_colon' => '');
     $defaults = array('labels' => $labels, 'public' => true, 'has_archive' => true, 'plural_view_adminbar' => false);
     $arguments = array_merge_recursive_distinct($defaults, $config);
     if (isset($arguments['plural_view_adminbar']) && $arguments['plural_view_adminbar']) {
         add_action('admin_bar_menu', function ($wp_admin_bar) use($type, $arguments) {
             $object = get_queried_object();
             if ($object->name == $type) {
                 $title = $object->labels->menu_name;
                 if (is_admin()) {
                     $url = get_post_type_archive_link($type);
                 } else {
                     $url = get_admin_url(null, 'edit.php?post_type=' . $type);
                 }
             }
             if ($object->post_type == $type) {
                 if (!is_admin()) {
                     $url = get_edit_post_link($object->ID);
                     $title = $arguments['labels']['edit_item'];
                 }
             }
             // Add admin bar entry
             if ($url) {
                 $wp_admin_bar->add_node(array('id' => 'custom-button', 'title' => $title, 'href' => $url));
             }
         }, 95);
     }
     register_post_type($type, $arguments);
 }
コード例 #8
0
function pending_submission_send_email($new_status, $old_status, $post)
{
    // Notifiy Admin that Contributor has writen a post
    if ($new_status == 'pending' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) {
        $pending_submission_email = get_option('pending_submission_notification_admin_email');
        $admins = get_option('admin_email');
        $url = get_permalink($post->ID);
        $edit_link = get_edit_post_link($post->ID, '');
        $preview_link = get_permalink($post->ID) . '&preview=true';
        $username = get_userdata($post->post_author);
        $subject = 'Nou article pendent: "' . $post->post_title . '"';
        $message = 'Un nou article per revisar.';
        $message .= "\r\n\r\n";
        $message .= "Autor: {$username->user_login}\r\n";
        $message .= "Títol: {$post->post_title}";
        $message .= "\r\n\r\n";
        $message .= "Edita: {$edit_link}\r\n";
        $message .= "Visualitza: {$preview_link}";
        $result = wp_mail($admins, $subject, $message);
    } else {
        if ($old_status == 'pending' && $new_status == 'publish' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) {
            $username = get_userdata($post->post_author);
            $url = get_permalink($post->ID);
            $subject = "El vostre article ha estat publicat:" . " " . $post->post_title;
            $message = '"' . $post->post_title . '"' . " ha estat aprovat i publicat. \r\n";
            $message .= $url;
            $result = wp_mail($username->user_email, $subject, $message);
        }
    }
}
コード例 #9
0
ファイル: admin.php プロジェクト: kalushta/darom
/**
 * Quick find a post.
 * @param  object $wp_query A WP_Query object.
 * @return void
 */
function appthemes_admin_quick_find_post($wp_query)
{
    global $pagenow;
    if ('edit.php' !== $pagenow) {
        return;
    }
    if (empty($wp_query->query_vars['s'])) {
        return;
    }
    $query = $wp_query->query_vars['s'];
    if ('#' !== substr($query, 0, 1)) {
        return;
    }
    $id = absint(substr($query, 1));
    if (!$id) {
        $wp_query->query_vars['s'] = 'Bad ID';
    }
    $post = get_post($id);
    if ($post) {
        $wp_query->query_vars['s'] = get_edit_post_link($id);
        wp_redirect('post.php?action=edit&post=' . $id);
        exit;
    } else {
        $wp_query->query_vars['s'] = 'Not Found';
    }
}
コード例 #10
0
function jl_brd_dashboard_recent_drafts($drafts = false)
{
    if (!$drafts) {
        $drafts_query = new WP_Query(array('post_type' => 'any', 'post_status' => array('draft', 'pending'), 'posts_per_page' => 150, 'orderby' => 'modified', 'order' => 'DESC'));
        $drafts =& $drafts_query->posts;
    }
    if ($drafts && is_array($drafts)) {
        $list = array();
        foreach ($drafts as $draft) {
            $url = get_edit_post_link($draft->ID);
            $title = _draft_or_post_title($draft->ID);
            $last_id = get_post_meta($draft->ID, '_edit_last', true);
            $last_user = get_userdata($last_id);
            $last_modified = '<i>' . esc_html($last_user->display_name) . '</i>';
            $item = '<h4><a href="' . $url . '" title="' . sprintf(__('Edit ?%s?'), esc_attr($title)) . '">' . esc_html($title) . '</a>' . '<abbr> ' . $draft->post_status . ' ' . $draft->post_type . '</abbr>' . '<abbr style="display:block;margin-left:0;">' . sprintf(__('Last edited by %1$s on %2$s at %3$s'), $last_modified, mysql2date(get_option('date_format'), $draft->post_modified), mysql2date(get_option('time_format'), $draft->post_modified)) . '</abbr></h4>';
            if ($the_content = preg_split('#\\s#', strip_shortcodes(strip_tags($draft->post_content), 11, PREG_SPLIT_NO_EMPTY))) {
                $item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
            }
            $list[] = $item;
        }
        ?>
	<ul>
		<li><?php 
        echo join("</li>\n<li>", $list);
        ?>
</li>
	</ul>
<?php 
    } else {
        _e('There are no drafts at the moment');
    }
}
コード例 #11
0
ファイル: posts-row.php プロジェクト: thetmkay/stage-craft
function render_orphans_row($post, $classes)
{
    $classes_string = implode(' ', $classes);
    ?>
<tr class="<?php 
    echo $classes_string;
    ?>
">
	<td class="post-title">
		<a href="<?php 
    echo get_edit_post_link($post->ID);
    ?>
"><?php 
    echo $post->post_title;
    ?>
</a>
	</td>
	<td class="post-is-parent">
		<?php 
    echo $post->stage_children;
    ?>
	</td>
	<td class="post-trash">
		<input name="post_id" type="hidden" value="<?php 
    echo $post->ID;
    ?>
">
		<button class="button button-primary button-large">Trash</button>
	</td>
</tr>
<?php 
}
コード例 #12
0
/**
 * Get the url of the Post for editing
 * @param type $post_id
 * @return type 
 */
function buddyblog_get_edit_url($post_id = false)
{
    $bp = buddypress();
    $user_id = get_current_user_id();
    if (!$user_id) {
        return;
    }
    if (empty($post_id)) {
        $post_id = get_the_ID();
    }
    //cheeck if current user can edit the post
    $post = get_post($post_id);
    //if the author of the post is same as the loggedin user or the logged in user is admin
    if ($post->post_type != buddyblog_get_posttype()) {
        return false;
    }
    if ($post->post_author != $user_id && !is_super_admin()) {
        return;
    }
    $action_name = 'edit';
    if (current_user_can(buddyblog_get_option('dashboard_edit_cap'))) {
        return get_edit_post_link($post);
    }
    //if we are here, we can allow user to edit the post
    return bp_core_get_user_domain($post->post_author) . $bp->buddyblog->slug . "/{$action_name}/" . $post->ID . '/';
}
コード例 #13
0
 /**
  * Perform redirect depending on entity uri and target
  *
  * @since 3.2.0
  */
 public function ajax_redirect()
 {
     if (!isset($_GET['uri'])) {
         wp_die('Entity uri missing');
     }
     if (!isset($_GET['to'])) {
         wp_die('Redirect target missing');
     }
     // Get the entity uri
     $entity_uri = $_GET['uri'];
     // Get the redirect target
     $target = $_GET['to'];
     if (null === ($entity_id = $this->entity_service->get_entity_post_by_uri($entity_uri))) {
         wp_die('Entity not found');
     }
     switch ($target) {
         case 'edit':
             $redirect_url = get_edit_post_link($entity_id, 'none');
             break;
         case 'lod':
             $redirect_url = self::LOD_ENDPOINT . '/lodview/?IRI=' . urlencode($entity_uri);
             break;
         case 'permalink':
             $redirect_url = get_permalink($entity_id);
             break;
         default:
             wp_die('Unsupported redirect target');
     }
     // Perform the redirect
     wp_safe_redirect($redirect_url);
 }
コード例 #14
0
 /** ************************************************************************
  * Recommended. This is a custom column method and is responsible for what
  * is rendered in any column with a name/slug of 'title'. Every time the class
  * needs to render a column, it first looks for a method named
  * column_{$column_title} - if it exists, that method is run. If it doesn't
  * exist, column_default() is called instead.
  *
  * This example also illustrates how to implement rollover actions. Actions
  * should be an associative array formatted as 'slug'=>'link html' - and you
  * will need to generate the URLs yourself. You could even ensure the links
  *
  *
  * @see WP_List_Table::::single_row_columns()
  * @param array $item A singular item (one full row's worth of data)
  * @return string Text to be placed inside the column <td> (movie title only)
  **************************************************************************/
 function column_post_title($item)
 {
     //Build row actions
     $actions = array('edit_choices' => sprintf('<a href="#" class="edit-gd-choice-inline" id="edit-gd-choice-inline-%s" data-postid="%s">Edit Choices</a>', $item->ID, $item->ID), 'edit' => sprintf('<a href="%s">Edit Step</a>', get_edit_post_link($item->ID)), 'view' => sprintf('<a href="%s">View Step</a>', get_permalink($item->ID)), 'delete' => sprintf('<a href="?page=%s&action=%s&gd_list_progress_pt[]=%s">Delete</a>', $_REQUEST['page'], 'delete', $item->ID));
     //Return the title contents
     return sprintf('%1$s %2$s %3$s', '<span class="gd_post_title_editable" data-stepid="' . $item->ID . '">' . $item->post_title . '</span>', $this->row_actions($actions), $this->render_progress_pt_choice_form($item->ID));
 }
コード例 #15
0
ファイル: wp.php プロジェクト: Br3nda/openmicroblogger
function render_comment(&$post, &$profile, &$parent)
{
    require 'wp-content/language/lang_chooser.php';
    //Loads the language-file
    global $request;
    $comments = "";
    $comments .= '<hr />';
    //  $cctime = date( "g:i A" , strtotime($post->created) );
    //  $ccdate = date( get_settings('date_format'), strtotime($post->created) );
    $ccurl = $request->url_for(array('resource' => 'posts', 'id' => $post->id));
    $ccrurl = 'JavaScript:inline_comment(' . $post->id . ',' . $parent->id . ');';
    $comments .= '<h4>';
    $comments .= ' <span class="meta">';
    //  $comments .= $cctime.' <em>on</em> '.$ccdate;
    $comments .= '<span class="actions">';
    $comments .= '<a href="' . $ccurl . '">Permalink</a>  | <a rel=\'nofollow\' class=\'comment-reply-link\' href="' . $ccrurl . '">' . $txt['wp_reply'] . '</a>';
    if (get_profile_id() == $post->profile_id) {
        $comments .= ' | <a href="' . get_edit_post_link($post) . '" class="post-edit-link" rel="' . $post->id . '">' . $txt['wp_Edit'] . '</a>';
        $comments .= ' | <a href="' . get_edit_post_link($post, 'remove') . '" class="post-remove-link" rel="' . $post->id . '">' . $txt['wp_remove'] . '</a>';
    }
    $comments .= '</span>';
    $comments .= '<br />';
    $comments .= '<img alt=\'image\' src=\'' . profile_get_avatar($profile) . '\' class=\'avatar avatar-32\' height=\'32\' width=\'32\' />';
    $comments .= '<a class="nick" href=\'' . base_path(true) . '' . $profile->nickname . '\'>' . $profile->nickname . '</a>&nbsp;';
    $comments .= laconica_time($post->created);
    $comments .= '</span>';
    $comments .= '</h4>';
    $comments .= '<div class="commentcontent" id="commentcontent-' . $post->id . '">';
    $comments .= '<p>' . render_notice($post->title, $post, $profile) . '</p>';
    $comments .= '</div>';
    return $comments;
}
コード例 #16
0
function jra_safe_to_delete_callback()
{
    global $wpdb;
    // this is how you get access to the database
    $sanitizedFile = sanitize_text_field($_POST['file']);
    $file_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_value = %s", $sanitizedFile));
    if (is_null($file_count)) {
        echo "<h2 style=\"color: green; font-weight: bold;\">This file [{$sanitizedFile}] is safe to delete! Do it.</h2>";
    } else {
        if ($file_count < 1) {
            echo "<h2 style=\"color: green; font-weight: bold;\">This file [{$sanitizedFile}] is safe to delete! Do it.</h2>";
        } else {
            echo "<h2 style=\"color: red; font-weight: bold;\">This file [{$sanitizedFile}] is not safe to delete!</h2>";
            echo "<p>{$sanitizedFile} is used {$file_count} time";
            if ($file_count != 1) {
                echo "s";
            }
            echo ":</p><ul style=\"margin-left: 0.5em;\">";
            $items = $wpdb->get_col($wpdb->prepare("SELECT ALL post_id FROM {$wpdb->postmeta} WHERE meta_value = %s", $sanitizedFile));
            foreach ($items as $item) {
                echo "<li><h3 style=\"display: inline-block; margin: 0 0 0.5em 0\">- " . get_the_title($item) . "</h3><p style=\"text-indent: 0.5em; display: inline-block; margin: 0 0 0.5em 0\"> <a href=\"" . get_permalink($item) . "\">View</a> | <a href=\"" . get_edit_post_link($item) . "\">Edit</a></p></li>";
            }
            echo "</ul>";
        }
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}
コード例 #17
0
function auto_post_twfc($post_ID)
{
    $post_title = get_the_title($post_ID);
    // titulo do post
    $post_url = get_permalink($post_ID);
    // url da post
    $redirect_uri = get_edit_post_link();
    // url de retorno / url do post
    // Imagem usada na postagem das redes sociais
    $imgRedes = get_post_meta($post_ID, 'imagemredes', true) ? get_post_meta($post_ID, 'imagemredes', true) : urlBase() . '/images/banners/posts/banner_post_redes.jpg';
    // pega os dados do post
    $postpp = get_post($post_ID);
    $post_description = strip_tags($postpp->post_content);
    // conteudo do post
    // array  com o conteudo do post
    $array = array('titulo' => $post_title, 'url' => $post_url, 'redirect' => $redirect_uri, 'imagem' => $imgRedes, 'conteudo' => $post_description);
    // inclui o arquivo para iniciar as classes facebook
    require_once FC_PATH . 'twfcfacebook.php';
    $postFace = new Twfcfacebook();
    $postFace->postFacebook($array);
    // inclui o arquivo para iniciar as classes twiiter
    require_once TW_PATH . 'twfctwitter.php';
    $postTwitter = new Twfctwitter();
    $postTwitter->postTwitter($array);
}
コード例 #18
0
ファイル: image.php プロジェクト: hunghoang179/sitenews
 /**
  * Get field HTML
  *
  * @param string $html
  * @param mixed  $meta
  * @param array  $field
  *
  * @return string
  */
 static function html($html, $meta, $field)
 {
     global $wpdb;
     $i18n_msg = _x('Uploaded files', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_del_file = _x('Delete this file', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_delete = _x('Delete', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_edit = _x('Edit', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_title = _x('Upload files', 'image upload', RWMB_TEXTDOMAIN);
     $i18n_more = _x('Add another file', 'image upload', RWMB_TEXTDOMAIN);
     $html = wp_nonce_field("rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false);
     $html .= wp_nonce_field("rwmb-reorder-images_{$field['id']}", "nonce-reorder-images_{$field['id']}", false, false);
     $html .= "<input type='hidden' class='field-id' value='{$field['id']}' />";
     // Uploaded images
     if (!empty($meta)) {
         $html .= "<h4>{$i18n_msg}</h4>";
         $html .= "<ul class='rwmb-images rwmb-uploaded'>";
         foreach ($meta as $image) {
             $src = wp_get_attachment_image_src($image, 'thumbnail');
             $src = $src[0];
             $link = get_edit_post_link($image);
             $html .= "<li id='item_{$image}'>\n\t\t\t\t\t\t<img src='{$src}' />\n\t\t\t\t\t\t<div class='rwmb-image-bar'>\n\t\t\t\t\t\t\t<a title='{$i18n_edit}' class='rwmb-edit-file' href='{$link}' target='_blank'>{$i18n_edit}</a> |\n\t\t\t\t\t\t\t<a title='{$i18n_del_file}' class='rwmb-delete-file' href='#' rel='{$image}'>{$i18n_delete}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>";
         }
         $html .= '</ul>';
     }
     // Show form upload
     $html .= "\n\t\t\t<h4>{$i18n_title}</h4>\n\t\t\t<div class='new-files'>\n\t\t\t\t<div class='file-input'><input type='file' name='{$field['id']}[]' /></div>\n\t\t\t\t<a class='rwmb-add-file' href='#'>{$i18n_more}</a>\n\t\t\t</div>";
     return $html;
 }
コード例 #19
0
 function admin_settings()
 {
     echo '<div class="wrap"><h1>' . get_admin_page_title() . '</h1>';
     $count_methods = array('public' => array('name' => __('Top %s posts', 'wpupostviews'), 'orig' => false), 'orig' => array('name' => __('Real top %s posts', 'wpupostviews'), 'orig' => true));
     foreach ($count_methods as $method) {
         $top_posts = $this->get_top_posts(false, $method['orig']);
         if (!empty($top_posts)) {
             echo '<hr />';
             echo '<h2>' . sprintf($method['name'], $this->options['default_top']) . '</h2>';
             echo '<ol>';
             foreach ($top_posts as $tp) {
                 echo '<li><a href="' . get_edit_post_link($tp->ID) . '"><strong>' . esc_attr($tp->post_title) . '</strong></a> (' . get_post_meta($tp->ID, 'wpupostviews_' . ($method['orig'] ? 'orig_' : '') . 'nbviews', 1) . ')</li>';
             }
             echo '</ol>';
         }
     }
     echo '<hr />';
     echo '<h2>' . __('Settings') . '</h2>';
     echo '<form action="options.php" method="post">';
     settings_fields($this->settings_details['option_id']);
     do_settings_sections($this->options['plugin_id']);
     echo submit_button(__('Save Changes', 'wpupostviews'));
     echo '</form>';
     echo '</div>';
 }
コード例 #20
0
function ceo_display_edit_link()
{
    global $post;
    if ($post->post_type == 'comic' && current_user_can('edit_post', $post->ID)) {
        echo '<a href="' . get_edit_post_link() . '">' . __('Edit Comic.', 'comiceasel') . "</a><br />\r\n";
    }
}
function crb_carbon_relationship_options($options, $name)
{
    foreach ($options as $index => $option) {
        $options[$index]['editlink'] = get_edit_post_link($option['id']);
    }
    return $options;
}
コード例 #22
0
ファイル: class.objects.php プロジェクト: taeche/SoDoEx
 /**
  *
  * @TODO document
  *
  */
 function button($text = '&nbsp;', $type = 'button', $color = 'grey', $args)
 {
     $defaults = array('size' => 'normal', 'align' => 'left', 'display' => null, 'style' => '', 'action' => '', 'pid' => 0, 'class' => null, 'clear' => false);
     $a = wp_parse_args($args, $defaults);
     $color_class = 'bl-' . $color;
     $size_class = 'bl-size-' . $a['size'];
     $position = 'bl-align-' . $a['align'];
     $classes = join(' ', array($color_class, $size_class, $position, $a['class']));
     $display = isset($a['display']) ? 'display: ' . $a['display'] : '';
     $post_link = get_edit_post_link($a['pid']);
     if ($type == 'edit_post') {
         $element = 'a';
         $classes .= ' post-edit-link';
         $action = sprintf('href="%s"', $post_link);
     } elseif ($type = 'link') {
         $element = 'a';
         $action = sprintf('href="%s"', $a['action']);
     } else {
         $element = 'span';
         $action = '';
     }
     $clear = $a['clear'] ? '<div class="p fix">' : '';
     $clear_end = $a['clear'] ? '</div>' : '';
     $button = sprintf('<%1$s class="blink" %3$s><span class="blink-pad">%2$s</span></%1$s>', $element, $text, $action);
     $output = sprintf('%s<div class="%s blink-wrap" style="%s">%s</div>%s', $clear, $classes, $display, $button, $clear_end);
     if ($type == 'edit_post' && !isset($post_link)) {
         return '';
     } else {
         return apply_filters('pagelines_button', $output, $a);
     }
 }
コード例 #23
0
 /**
  * Get the URL that will edit the current post/object
  *
  * @return bool|string
  */
 function get_edit_url()
 {
     if ($this->can_edit()) {
         return get_edit_post_link($this->ID);
     }
     return false;
 }
コード例 #24
0
/**
 * Change location list column content
 *
 * @since 0.9
 * @param string $column Column being worked on
 */
function ctc_location_columns_content($column)
{
    global $post;
    switch ($column) {
        // Thumbnail
        case 'ctc_location_thumbnail':
            if (has_post_thumbnail()) {
                echo '<a href="' . get_edit_post_link($post->ID) . '">' . get_the_post_thumbnail($post->ID, array(80, 80)) . '</a>';
            }
            break;
            // Address
        // Address
        case 'ctc_location_address':
            echo nl2br(strip_tags(get_post_meta($post->ID, '_ctc_location_address', true)));
            break;
            // Times
        // Times
        case 'ctc_location_times':
            echo nl2br(strip_tags(get_post_meta($post->ID, '_ctc_location_times', true)));
            break;
            // Order
        // Order
        case 'ctc_location_order':
            echo isset($post->menu_order) ? $post->menu_order : '';
            break;
    }
}
コード例 #25
0
ファイル: post.php プロジェクト: fka2004/webkit
/**
 * Redirect to previous page.
 *
 * @param int $post_id Optional. Post ID.
 */
function redirect_post($post_id = '')
{
    if (isset($_POST['save']) || isset($_POST['publish'])) {
        $status = get_post_status($post_id);
        if (isset($_POST['publish'])) {
            switch ($status) {
                case 'pending':
                    $message = 8;
                    break;
                case 'future':
                    $message = 9;
                    break;
                default:
                    $message = 6;
            }
        } else {
            $message = 'draft' == $status ? 10 : 1;
        }
        $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url'));
    } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
        $location = add_query_arg('message', 2, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
        $location = add_query_arg('message', 3, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif ('post-quickpress-save-cont' == $_POST['action']) {
        $location = "post.php?action=edit&post={$post_id}&message=7";
    } else {
        $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url'));
    }
    wp_redirect(apply_filters('redirect_post_location', $location, $post_id));
    exit;
}
コード例 #26
0
ファイル: wp-npr-api.php プロジェクト: appliaison/WP-NPR-API
 function load_page_hook()
 {
     if (isset($_POST) && isset($_POST['story_id'])) {
         $story_id = absint($_POST['story_id']);
     } else {
         if (isset($_GET['create_draft']) && isset($_GET['story_id'])) {
             $story_id = absint($_GET['story_id']);
         }
     }
     if (isset($story_id)) {
         // XXX: check that the API key is actually set
         $api = new NPR_API_Client(get_option(NPR_API_KEY_OPTION));
         $story = $api->story_from_id($story_id);
         if (!$story) {
             // XXX: handle error
             return;
         }
         $poster = new Story_Poster();
         $resp = $poster->update_post_from_story($story);
         $created = $resp[0];
         $id = $resp[1];
         if ($created) {
             $msg = sprintf('Created <a href="%s">%s</a> as a Draft.', get_edit_post_link($id), $story->title);
         } else {
             $msg = sprintf('Updated <a href="%s">%s</a>.', get_edit_post_link($id), $story->title);
         }
         $this->created_message = $msg;
     }
 }
コード例 #27
0
 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);
 }
コード例 #28
0
 /**
  * Render entry info of the specified form and lead
  *
  * @param string $form_id
  * @param array $lead
  */
 public static function entry_info($form_id, $lead)
 {
     $payment_id = gform_get_meta($lead['id'], 'pronamic_payment_id');
     if ($payment_id) {
         printf('<a href="%s">%s</a>', esc_attr(get_edit_post_link($payment_id)), esc_html(get_the_title($payment_id)));
     }
 }
コード例 #29
-1
ファイル: post.php プロジェクト: OneTimeUser/retailwire
 /**
  * @see CPAC_Column::get_value()
  * @since 2.4.7
  */
 public function get_value($id)
 {
     $raw_value = $this->get_raw_value($id);
     // Get page to link to
     switch ($this->get_option('post_link_to')) {
         case 'edit_post':
             $link = get_edit_post_link($raw_value);
             break;
         case 'view_post':
             $link = get_permalink($raw_value);
             break;
         case 'edit_author':
             $link = get_edit_user_link(get_post_field('post_author', $raw_value));
             break;
         case 'view_author':
             $link = get_author_posts_url(get_post_field('post_author', $raw_value));
             break;
     }
     // Get property of post to display
     switch ($this->get_option('post_property_display')) {
         case 'author':
             $label = get_the_author_meta('display_name', get_post_field('post_author', $raw_value));
             break;
         case 'id':
             $label = $raw_value;
             break;
         default:
             $label = get_the_title($raw_value);
             break;
     }
     $value = $link ? "<a href='{$link}'>{$label}</a>" : $label;
     return $value;
 }
コード例 #30
-1
    /**
     * The template part for displaying page content
     *
     * @package Customizr
     * @since Customizr 3.0
     */
    function tc_content_page()
    {
        ?>
        <header>
             <?php 
        if (!is_front_page()) {
            ?>
                 <?php 
            printf('<h1 class="entry-title format-icon">%1$s %2$s</h1>', get_the_title(), is_user_logged_in() && current_user_can('edit_pages') ? '<span class="edit-link btn btn-inverse btn-mini"><a class="post-edit-link" href="' . get_edit_post_link() . '" title="' . __('Edit page', 'customizr') . '">' . __('Edit page', 'customizr') . '</a></span>' : '');
            ?>
                <hr class="featurette-divider">
             <?php 
        }
        ?>
        </header>

        <div class="entry-content">
            <?php 
        the_content(__('Continue reading <span class="meta-nav">&rarr;</span>', 'customizr'));
        ?>
        </div>

           <?php 
        wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'customizr'), 'after' => '</div>'));
        ?>

        <footer class="entry-meta">

        </footer><!-- .entry-meta -->
        <?php 
    }