This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Пример #1
0
$more = count($discourse_info->posts) == 0 ? "" : "more ";
if ($more_replies == 0) {
    $more_replies = "";
} elseif ($more_replies == 1) {
    $more_replies = "1 " . $more . "reply";
} else {
    $more_replies = $more_replies . " " . $more . "replies";
}
$discourse_url = esc_url($options['url']);
$discourse_html = '';
$comments_html = '';
$participants_html = '';
if (count($discourse_info->posts) > 0) {
    foreach ($discourse_info->posts as &$post) {
        $comment_html = wp_kses_post($options['comment-html']);
        $replace_array = array('{discourse_url}' => $discourse_url, '{discourse_url_name}' => $discourse_url_name, '{topic_url}' => $permalink, '{avatar_url}' => Discourse::avatar($post->avatar_template, 64), '{user_url}' => Discourse::homepage($options['url'], $post), '{username}' => $post->username, '{comment_body}' => Discourse::convert_relative_img_src_to_absolute($discourse_url, $post->cooked), '{comment_url}' => "{$permalink}/{$post->post_number}", '{comment_created_at}' => mysql2date(get_option('date_format'), $post->created_at));
        $comments_html .= str_replace(array_keys($replace_array), array_values($replace_array), $comment_html);
    }
    foreach ($discourse_info->participants as &$participant) {
        $participant_html = wp_kses_post($options['participant-html']);
        $replace_array = array('{discourse_url}' => $discourse_url, '{discourse_url_name}' => $discourse_url_name, '{topic_url}' => $permalink, '{avatar_url}' => Discourse::avatar($participant->avatar_template, 64), '{user_url}' => Discourse::homepage($options['url'], $participant), '{username}' => $participant->username);
        $participants_html .= str_replace(array_keys($replace_array), array_values($replace_array), $participant_html);
    }
    $discourse_html = wp_kses_post($options['replies-html']);
    $discourse_html = str_replace('{more_replies}', $more_replies, $discourse_html);
} else {
    $discourse_html = wp_kses_post($options['no-replies-html']);
}
$replace_array = array('{discourse_url}' => $discourse_url, '{discourse_url_name}' => $discourse_url_name, '{topic_url}' => $permalink, '{comments}' => $comments_html, '{participants}' => $participants_html);
$discourse_html = str_replace(array_keys($replace_array), array_values($replace_array), $discourse_html);
echo $discourse_html;
Пример #2
0
 function publish_to_discourse()
 {
     global $post;
     $options = Discourse::get_plugin_options();
     if (in_array($post->post_type, $options['allowed_post_types'])) {
         if ($post->post_status == 'auto-draft') {
             $value = $options['auto-publish'];
         } else {
             $value = get_post_meta($post->ID, 'publish_to_discourse', true);
         }
         echo '<div class="misc-pub-section misc-pub-section-last">
        <span>' . '<input type="hidden" name="showed_publish_option" value="1">' . '<label><input type="checkbox"' . ($value == "1" ? ' checked="checked" ' : null) . 'value="1" name="publish_to_discourse" /> Publish to Discourse</label>' . '</span></div>';
     }
 }
Пример #3
0
 function publish_to_discourse()
 {
     global $post;
     $options = Discourse::get_plugin_options();
     if (in_array($post->post_type, $options['allowed_post_types'])) {
         if ($post->post_status == 'auto-draft') {
             $value = $options['auto-publish'];
         } else {
             $value = get_post_meta($post->ID, 'publish_to_discourse', true);
         }
         $categories = self::get_discourse_categories('0');
         if (is_wp_error($categories)) {
             echo '<span>' . __('Unable to retrieve Discourse categories. Please check the wp-discourse plugin settings page to establish a connection.', 'wp-discourse') . '</span>';
         } else {
             echo '<div class="misc-pub-section misc-pub-section-discourse">';
             echo '<label>' . __('Publish to Discourse: ', 'wp-discourse') . '</label>';
             echo '<input type="checkbox"' . ($value == "1" ? ' checked="checked" ' : null) . 'value="1" name="publish_to_discourse" />';
             echo '</div>';
             echo '<div class="misc-pub-section misc-pub-section-category">' . '<input type="hidden" name="showed_publish_option" value="1">';
             echo '<label>' . __('Discourse Category: ', 'wp-discourse') . '</label>';
             $publish_post_category = get_post_meta($post->ID, 'publish_post_category', true);
             $default_category = isset($options['publish-category']) ? $options['publish-category'] : '';
             $selected = !empty($publish_post_category) ? $publish_post_category : $default_category;
             self::option_input('publish_post_category', $categories, $selected);
             echo '</div>';
         }
     }
 }
Пример #4
0
        $comment_html = str_replace('{avatar_url}', esc_url(Discourse::avatar($post->avatar_template, 64)), $comment_html);
        $comment_html = str_replace('{user_url}', esc_url(Discourse::homepage($options['url'], $post)), $comment_html);
        $comment_html = str_replace('{username}', esc_html($post->username), $comment_html);
        $comment_html = str_replace('{fullname}', esc_html($post->name), $comment_html);
        $comment_html = str_replace('{comment_body}', wp_kses_post($post->cooked), $comment_html);
        // emoticons don't have absolute urls
        $comment_html = str_replace('{comment_created_at}', mysql2date(get_option('date_format'), $post->created_at), $comment_html);
        $comments_html .= $comment_html;
    }
    foreach ($discourse_info->participants as &$participant) {
        $participant_html = wp_kses_post(Discourse::participant_html());
        $participant_html = str_replace('{discourse_url}', esc_url($options['url']), $participant_html);
        $participant_html = str_replace('{discourse_url_name}', esc_html($discourse_url_name), $participant_html);
        $participant_html = str_replace('{topic_url}', esc_url($permalink), $participant_html);
        $participant_html = str_replace('{avatar_url}', esc_url(Discourse::avatar($participant->avatar_template, 64)), $participant_html);
        $participant_html = str_replace('{user_url}', esc_url(Discourse::homepage($options['url'], $participant)), $participant_html);
        $participant_html = str_replace('{username}', esc_html($participant->username), $participant_html);
        $participant_html = str_replace('{fullname}', esc_html($participant->name), $participant_html);
        $participants_html .= $participant_html;
    }
    $discourse_html = wp_kses_post(Discourse::replies_html());
    $discourse_html = str_replace('{more_replies}', esc_html($more_replies), $discourse_html);
} else {
    $discourse_html = wp_kses_post(Discourse::no_replies_html());
}
$discourse_html = str_replace('{discourse_url}', esc_url($options['url']), $discourse_html);
$discourse_html = str_replace('{discourse_url_name}', esc_html($discourse_url_name), $discourse_html);
$discourse_html = str_replace('{topic_url}', esc_url($permalink), $discourse_html);
$discourse_html = str_replace('{comments}', wp_kses_post($comments_html), $discourse_html);
$discourse_html = str_replace('{participants}', wp_kses_post($participants_html), $discourse_html);
echo $discourse_html;
Пример #5
0
         $comment_html = str_replace('{user_url}', esc_url($user_url), $comment_html);
         $comment_html = str_replace('{username}', esc_html($post->username), $comment_html);
         $comment_html = str_replace('{fullname}', esc_html($post->name), $comment_html);
         $comment_body = Discourse::convert_relative_img_src_to_absolute($discourse_url, $post->cooked);
         $comment_html = str_replace('{comment_body}', wp_kses_post($comment_body), $comment_html);
         $comment_html = str_replace('{comment_created_at}', mysql2date($datetime_format, get_date_from_gmt($post->created_at)), $comment_html);
         $comments_html .= $comment_html;
     }
     foreach ($discourse_info->participants as &$participant) {
         $participant_html = wp_kses_post(Templates\HTMLTemplates::participant_html());
         $participant_html = str_replace('{discourse_url}', $discourse_url, $participant_html);
         $participant_html = str_replace('{discourse_url_name}', $discourse_url_name, $participant_html);
         $participant_html = str_replace('{topic_url}', $permalink, $participant_html);
         $avatar_url = Discourse::avatar($participant->avatar_template, 64);
         $participant_html = str_replace('{avatar_url}', esc_url($avatar_url), $participant_html);
         $user_url = Discourse::homepage($options['url'], $participant);
         $participant_html = str_replace('{user_url}', esc_url($user_url), $participant_html);
         $participant_html = str_replace('{username}', esc_html($participant->username), $participant_html);
         $participants_html .= $participant_html;
     }
     $discourse_html = wp_kses_post(Templates\HTMLTemplates::replies_html());
     $discourse_html = str_replace('{more_replies}', $more_replies, $discourse_html);
 } else {
     $discourse_html = wp_kses_post(Templates\HTMLTemplates::no_replies_html());
 }
 $discourse_html = str_replace('{discourse_url}', $discourse_url, $discourse_html);
 $discourse_html = str_replace('{discourse_url_name}', $discourse_url_name, $discourse_html);
 $discourse_html = str_replace('{topic_url}', $permalink, $discourse_html);
 $discourse_html = str_replace('{comments}', $comments_html, $discourse_html);
 $discourse_html = str_replace('{participants}', $participants_html, $discourse_html);
 echo $discourse_html;
Пример #6
0
        $comment_html = str_replace('{topic_url}', $permalink, $comment_html);
        $comment_html = str_replace('{avatar_url}', Discourse::avatar($post->avatar_template, 64), $comment_html);
        $comment_html = str_replace('{user_url}', Discourse::homepage($options['url'], $post), $comment_html);
        $comment_html = str_replace('{username}', $post->username, $comment_html);
        $comment_html = str_replace('{fullname}', $post->name, $comment_html);
        $comment_html = str_replace('{comment_body}', Discourse::convert_relative_img_src_to_absolute($discourse_url, $post->cooked), $comment_html);
        $comment_html = str_replace('{comment_created_at}', mysql2date($datetime_format, get_date_from_gmt($post->created_at)), $comment_html);
        $comments_html .= $comment_html;
    }
    foreach ($discourse_info->participants as &$participant) {
        $participant_html = wp_kses_post($options['participant-html']);
        $participant_html = str_replace('{discourse_url}', $discourse_url, $participant_html);
        $participant_html = str_replace('{discourse_url_name}', $discourse_url_name, $participant_html);
        $participant_html = str_replace('{topic_url}', $permalink, $participant_html);
        $participant_html = str_replace('{avatar_url}', Discourse::avatar($participant->avatar_template, 64), $participant_html);
        $participant_html = str_replace('{user_url}', Discourse::homepage($options['url'], $participant), $participant_html);
        $participant_html = str_replace('{username}', $participant->username, $participant_html);
        $participant_html = str_replace('{fullname}', $participant->name, $participant_html);
        $participants_html .= $participant_html;
    }
    $discourse_html = wp_kses_post($options['replies-html']);
    $discourse_html = str_replace('{more_replies}', $more_replies, $discourse_html);
} else {
    $discourse_html = wp_kses_post($options['no-replies-html']);
}
$discourse_html = str_replace('{discourse_url}', $discourse_url, $discourse_html);
$discourse_html = str_replace('{discourse_url_name}', $discourse_url_name, $discourse_html);
$discourse_html = str_replace('{topic_url}', $permalink, $discourse_html);
$discourse_html = str_replace('{comments}', $comments_html, $discourse_html);
$discourse_html = str_replace('{participants}', $participants_html, $discourse_html);
echo $discourse_html;