function hw_yarpp_make_optin_classy($classes)
{
    if (!hw_yarpp_get_option('optin')) {
        $classes[] = 'hw_yarpp_attention';
    }
    return $classes;
}
 public function display()
 {
     $output = '<p>' . 'Enable the free <a href="http://www.yarpp.com" target="_blank">YARPP Pro enhancements</a> to add even ' . 'more power to your blog or website!' . '<br/><br/>' . '<a href="' . plugins_url('/', dirname(__FILE__)) . 'includes/hw_yarpp_switch.php" class="hw_yarpp_switch_button button" data-go="pro">Turn them on now</a>&nbsp;&nbsp;' . '<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>' . '</p>' . '<p>' . 'We can continue to improve the YARPP product for you if we know how it&#39;s used. Please help us by ' . 'allowing usage data to be sent back.' . '<br/>' . '</p>' . '<input
             type="checkbox"
             id="hw-yarpp-optin"
             name="optin"
             value="true" ' . checked(hw_yarpp_get_option('optin') == 1, true, false) . ' ' . '/>' . '<label for="yarpp-optin">Send usage data back.</label>' . '<a href="#" id="yarpp-optin-learnmore" style="float:right;text-decoration:underline">Learn More</a>';
     echo $output;
 }
    public function displayorder($option, $class = null)
    {
        echo "<div class='hw_yarpp_form_row hw_yarpp_form_select {$class}'><div class='hw_yarpp_form_label'>";
        _e("Order results:", 'hw-yarpp');
        echo "</div><div><select name='{$option}' id='<?php echo {$option}; ?>'>";
        $order = hw_yarpp_get_option($option);
        ?>
                <option value="score DESC" <?php 
        echo $order == 'score DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("score (high relevance to low)", 'hw-yarpp');
        ?>
</option>
                <option value="score ASC" <?php 
        echo $order == 'score ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("score (low relevance to high)", 'hw-yarpp');
        ?>
</option>
                <option value="post_date DESC" <?php 
        echo $order == 'post_date DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("date (new to old)", 'hw-yarpp');
        ?>
</option>
                <option value="post_date ASC" <?php 
        echo $order == 'post_date ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("date (old to new)", 'hw-yarpp');
        ?>
</option>
                <option value="post_title ASC" <?php 
        echo $order == 'post_title ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("title (alphabetical)", 'hw-yarpp');
        ?>
</option>
                <option value="post_title DESC" <?php 
        echo $order == 'post_title DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("title (reverse alphabetical)", 'hw-yarpp');
        ?>
</option>
                <?php 
        echo "</select></div></div>";
    }
 public function display()
 {
     global $hw_yarpp;
     echo "<div style='overflow:auto'>";
     echo '<div class="rss_displayed hw_yarpp_code_display"';
     if (!$hw_yarpp->get_option('code_display')) {
         echo ' style="display: none;"';
     }
     echo '><b>' . __("RSS display code example", 'hw-yarpp') . '</b><br /><small>' . __("(Update options to reload.)", 'hw-yarpp') . "</small><br/><div id='display_demo_rss'></div></div>";
     $this->checkbox('rss_display', __("Display related posts in feeds?", 'hw-yarpp') . " <span class='hw_yarpp_help' data-help='" . esc_attr(__("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.", 'hw-yarpp')) . "'>&nbsp;</span>", '');
     $this->checkbox('rss_excerpt_display', __("Display related posts in the descriptions?", 'hw-yarpp') . " <span class='hw_yarpp_help' data-help='" . esc_attr(__("This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.", 'hw-yarpp')) . "'>&nbsp;</span>", 'rss_displayed');
     $this->textbox('rss_limit', __('Maximum number of related posts:', 'hw-yarpp'), 2, 'rss_displayed');
     $this->template_checkbox(true, 'rss_displayed');
     echo "</div>";
     $chosen_template = hw_yarpp_get_option("rss_template");
     $choice = false === $chosen_template ? 'builtin' : ($chosen_template == 'thumbnails' ? 'thumbnails' : 'custom');
     echo "<div class='postbox hw_yarpp_subbox template_options_custom rss_displayed'";
     if ($choice != 'custom') {
         echo ' style="display: none;"';
     }
     echo ">";
     echo '<div class="hw_yarpp_form_row"><div>' . $this->template_text . '</div></div>';
     $this->template_file(true);
     echo "</div>";
     echo "<div class='postbox hw_yarpp_subbox template_options_thumbnails'";
     if ($choice != 'thumbnails') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->textbox('rss_thumbnails_heading', __('Heading:', 'hw-yarpp'), 40);
     $this->textbox('rss_thumbnails_default', __('Default image (URL):', 'hw-yarpp'), 40);
     $this->textbox('rss_no_results', __('Default display if no results:', 'hw-yarpp'), 40, 'sync_rss_no_results');
     echo "</div>";
     echo "<div class='postbox hw_yarpp_subbox template_options_builtin rss_displayed'";
     if ($choice != 'builtin') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->beforeafter(array('rss_before_related', 'rss_after_related'), __("Before / after related entries:", 'hw-yarpp'), 15, '', __("For example:", 'hw-yarpp') . ' &lt;ol&gt;&lt;/ol&gt;' . __(' or ', 'hw-yarpp') . '&lt;div&gt;&lt;/div&gt;');
     $this->beforeafter(array('rss_before_title', 'rss_after_title'), __("Before / after each related entry:", 'hw-yarpp'), 15, '', __("For example:", 'hw-yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'hw-yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->checkbox('rss_show_excerpt', __("Show excerpt?", 'hw-yarpp'), 'show_excerpt');
     $this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):', 'hw-yarpp'), 10, 'excerpted');
     $this->beforeafter(array('rss_before_post', 'rss_after_post'), __("Before / after (excerpt):", 'hw-yarpp'), 10, 'excerpted', __("For example:", 'hw-yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'hw-yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->textbox('rss_no_results', __('Default display if no results:', 'hw-yarpp'), 40, 'sync_rss_no_results');
     echo "</div>";
     $this->displayorder('rss_order', 'rss_displayed');
     //$this->checkbox( 'rss_promote_yarpp', __( "Help promote Yet Another Related Posts Plugin?", 'hw-yarpp' ) . " <span class='hw_yarpp_help' data-help='" . esc_attr( sprintf( __( "This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'hw-yarpp' ), "<code>" . htmlspecialchars( sprintf( __( "Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.", 'hw-yarpp' ), 'http://www.yarpp.com' ) )."</code>" ) ) . "'>&nbsp;</span>", 'rss_displayed' );
 }
 public function exclude($taxonomy, $string)
 {
     global $hw_yarpp;
     echo "<div class='hw_yarpp_form_row hw_yarpp_form_exclude'><div class='hw_yarpp_form_label'>";
     echo $string;
     echo "</div><div class='hw_yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
     $exclude_tt_ids = wp_parse_id_list(hw_yarpp_get_option('exclude'));
     $exclude_term_ids = $hw_yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
     if (count($exclude_term_ids)) {
         $terms = get_terms($taxonomy, array('include' => $exclude_term_ids));
         foreach ($terms as $term) {
             echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label> ";
         }
     }
     echo "</div></div></div>";
 }
        /**
         * render ouput metabox
         */
        public function display()
        {
            $pts = get_post_types('', 'objects');
            //list all registered post types
            ?>
        <div>
            <strong>Kích hoạt bài viết liên quan với post types dưới đây:</strong><br/>
        <?php 
            //enable yarpp for bellow posts type
            $post_types = hw_yarpp_get_option('hwrp_allow_post_types');
            foreach ($pts as $post_type) {
                echo "<label for='hwrp_allow_post_type_{$post_type->name}'><input id='hwrp_allow_post_type_{$post_type->name}' name='hwrp_allow_post_types[{$post_type->name}]' type='checkbox' ";
                checked(in_array($post_type->name, (array) $post_types));
                echo "/> {$post_type->labels->name}</label> ";
            }
            ?>
            <p><em>Sau đó tại mục ("Relatedness" options) lựa chọn những post types sẽ sử dụng để truy xuất related posts.</em>
            <em>Lưu ý: thay đổi lại post types hỗ trợ với YARPP bạn cần load lại trang 1 lần nữa sau khi lưu thay đổi cài đặt. Điều này sẽ update lại mục ("Relatedness" options).</em>
            </p>
        </div>

        <?php 
            //$this->textbox( 'h1', __( 'Match threshold:', 'hwrp' ) );
            $this->checkbox('hwrp_disable_yarpp_css', __("Không sử dụng CSS mặc định của YARPP?", 'hwrp'));
            //display related data post type templates options
            $this->display_table_posttype_templates();
        }
 /**
  * dequeue footer styles & scripts
  */
 public function _disable_yarpp_stylesheet_dequeue_footer_styles()
 {
     $disable_yarpp_css = hw_yarpp_get_option('hwrp_disable_yarpp_css');
     if ($disable_yarpp_css) {
         wp_dequeue_style('hw-yarppRelatedCss');
     }
 }
<?php

if (isset($_POST['myisam_override'])) {
    hw_yarpp_set_option('myisam_override', true);
    $enabled = $hw_yarpp->enable_fulltext();
    if ($enabled) {
        update_option('hw_yarpp_fulltext_disabled', 0);
        echo '<div class="updated" style="padding:5px">' . __('The MyISAM check has been overridden. You may now use the "consider titles" and "consider bodies" relatedness criteria.', 'hw-yarpp') . "</div>";
    } else {
        hw_yarpp_set_option('myisam_override', 0);
        echo '<div class="updated" style="padding:5px">' . '<span style="color:red;font-weight:bold">Fulltext Index creation did not work!</span><br/>' . 'Trying to force fulltext indexing on your table resulted in an error. Your posts table does not have fulltext indexing capabilities.<br/>' . 'The "consider titles" and "consider bodies" relatedness criteria will remain disabled.' . '</div>';
    }
}
$table_type = $hw_yarpp->diagnostic_myisam_posts();
if ((bool) $table_type !== true) {
    $hw_yarpp->disable_fulltext();
}
if (!(bool) hw_yarpp_get_option('myisam_override') && (bool) $hw_yarpp->diagnostic_fulltext_disabled()) {
    echo "<div class='updated' style='padding:15px'>" . '<p>' . '<strong>"Consider Titles"</strong> and <strong>"Consider Bodies"</strong> are currently disabled. ' . 'As a result, "Pages" may not display in the "Related Posts" sections.' . '&nbsp;&nbsp;<a href="#" id="hw_yarpp_fulltext_expand">Show Details [+]</a>' . '</p>' . '<div id="hw_yarpp_fulltext_details" class="hidden">' . '<p>' . sprintf('YARPP&#39;s "consider titles" and "consider bodies" relatedness criteria require your <code>%s</code> ' . 'table to use the <code>MyISAM</code> engine' . 'fulltext indexing feature. Unfortunately your table seems to be using the <code>%s</code> engine. ' . 'Because fulltext indexing is not supported by your current table engine, these two options have been disabled.', $wpdb->posts, $table_type) . '</p>' . '<p>' . sprintf('To restore these features, please do the following:<br/>' . '<ol>' . '<li>' . 'Convert your <code>%s</code> table to <code>MyISAM</code> engine by executing the ' . 'following SQL code on your MySQL client or terminal:<br/>' . '<code style="display:inline-block;margin:1.5em 1em">ALTER TABLE `%s` ENGINE = MyISAM;</code>' . '</li>', $wpdb->posts, $wpdb->posts) . sprintf('<li>' . 'Once your <code>%s</code> table has been successfully converted to the <code>MyISAM</code> engine, ' . 'click the button below to create the fulltext indices.<br/>', $wpdb->posts) . '<form method="post" style="display:inline-block;margin:1.5em 1em">' . "<input type='submit' class='button' name='myisam_override' value='Create fulltext indexes'/>" . "</form>" . '</li>' . '</ol>' . "</p>" . '<p>' . 'Note that, although no data should be lost by altering the table&#39;s engine, it is always recommended to perform a ' . 'full backup of the data before attempting to perform changes to your database.<br/>' . 'See MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html" target="_blank">storage engines</a> ' . 'documentation for details on MySQL engines.' . '</p>' . '</div>' . "</div>";
}
    <td>Kiểu dữ liệu</td>
    <td>Giao diện</td>
    <td>Giao diện từ HWTPL</td>
    <td>Giao diện box</td>
    <td>Giao diện box widget</td>
    <td>Tiêu đề</td>
    <td>Danh mục áp dụng</td>
    <td>Áp dụng tất</td>
    <td>Xem trước</td>
</tr>
<?php 
    global $hw_yarpp;
    //_print(yarpp_get_option('hw1'));
    $allow_pts = $hw_yarpp->get_option('hwrp_allow_post_types');
    //allow post types for using yarpp
    $skins = hw_yarpp_get_option('hwrp_skins');
    //get skins for support post types
    $pts = get_post_types('', 'objects');
    //list all registered post types
    //skin preview
    $init_skin_preview = false;
    if (is_array($allow_pts)) {
        foreach ($allow_pts as $post_type) {
            $aSkin_field_name = 'hwrp_skins[' . $post_type . ']';
            //field skins data
            //get all taxonomy terms assign to post type
            $terms = hwrp_get_all_terms_taxonomies($post_type);
            $active_skin4pt = isset($skins[$post_type]['skin']) ? $skins[$post_type]['skin'] : '';
            //active skin for this post type
            $pt = $pts[$post_type];
            //get post type object
 public function display()
 {
     global $hw_yarpp;
     echo "<div style='overflow:auto'>";
     echo '<div class="hw_yarpp_code_display"';
     if (!$hw_yarpp->get_option('code_display')) {
         echo ' style="display: none;"';
     }
     echo '><strong>' . __("Website display code example", 'hw-yarpp') . '</strong><br /><small>' . __("(Update options to reload.)", 'hw-yarpp') . "</small><br/><div id='display_demo_web'></div></div>";
     echo "<div class='hw_yarpp_form_row hw_yarpp_form_post_types'><div>";
     echo 'Automatically display related content from YARPP Basic on: ';
     echo " <span class='hw_yarpp_help' data-help='" . esc_attr(__("This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files.", 'hw-yarpp')) . "'>&nbsp;</span>&nbsp;&nbsp;";
     echo "</div><div>";
     $post_types = hw_yarpp_get_option('auto_display_post_types');
     foreach ($hw_yarpp->get_post_types('objects') as $post_type) {
         echo "<label for='hw_yarpp_post_type_{$post_type->name}'><input id='hw_yarpp_post_type_{$post_type->name}' name='auto_display_post_types[{$post_type->name}]' type='checkbox' ";
         checked(in_array($post_type->name, $post_types));
         echo "/> {$post_type->labels->name}</label> ";
     }
     echo "</div></div>";
     $this->checkbox('auto_display_archive', __("Also display in archives", 'hw-yarpp'));
     $this->textbox('limit', __('Maximum number of related posts:', 'hw-yarpp'));
     $this->template_checkbox(false);
     echo "</div>";
     $chosen_template = hw_yarpp_get_option("template");
     $choice = false === $chosen_template ? 'builtin' : ($chosen_template == 'thumbnails' ? 'thumbnails' : 'custom');
     echo "<div class='postbox hw_yarpp_subbox template_options_custom'";
     if ($choice != 'custom') {
         echo ' style="display: none;"';
     }
     echo ">";
     echo '<div class="hw_yarpp_form_row"><div>' . $this->template_text . '</div></div>';
     $this->template_file(false);
     echo "</div>";
     echo "<div class='postbox hw_yarpp_subbox template_options_thumbnails'";
     if ($choice != 'thumbnails') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->textbox('thumbnails_heading', __('Heading:', 'hw-yarpp'), 40);
     $this->textbox('thumbnails_default', __('Default image (URL):', 'hw-yarpp'), 40);
     $this->textbox('no_results', __('Default display if no results:', 'hw-yarpp'), 40, 'sync_no_results');
     echo "</div>";
     echo "<div class='postbox hw_yarpp_subbox template_options_builtin'";
     if ($choice != 'builtin') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->beforeafter(array('before_related', 'after_related'), __("Before / after related entries:", 'hw-yarpp'), 15, '', __("For example:", 'hw-yarpp') . ' &lt;ol&gt;&lt;/ol&gt;' . __(' or ', 'hw-yarpp') . '&lt;div&gt;&lt;/div&gt;');
     $this->beforeafter(array('before_title', 'after_title'), __("Before / after each related entry:", 'hw-yarpp'), 15, '', __("For example:", 'hw-yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'hw-yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->checkbox('show_excerpt', __("Show excerpt?", 'hw-yarpp'), 'show_excerpt');
     $this->textbox('excerpt_length', __('Excerpt length (No. of words):', 'hw-yarpp'), 10, 'excerpted');
     $this->beforeafter(array('before_post', 'after_post'), __("Before / after (excerpt):", 'hw-yarpp'), 10, 'excerpted', __("For example:", 'hw-yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'hw-yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->textbox('no_results', __('Default display if no results:', 'hw-yarpp'), 40, 'sync_no_results');
     echo "</div>";
     $this->displayorder('order');
     /*$this->checkbox(
           'promote_yarpp',
           __( "Help promote Yet Another Related Posts Plugin?", 'hw-yarpp' ).
           '<span class="yarpp_help" data-help="'.
           'This option will add the line &ldquo;powered by AdBistro&rdquo; beneath the related posts section. '.
           'This link is greatly appreciated."></span>'
       );*/
 }
<?php

global $wpdb, $wp_version, $hw_yarpp;
/* Enforce YARPP setup: */
$hw_yarpp->enforce();
if (!$hw_yarpp->enabled() && !$hw_yarpp->activate()) {
    echo '<div class="updated">' . __('The YARPP database has an error which could not be fixed.', 'hw-yarpp') . '</div>';
}
/* Check to see that templates are in the right place */
if (!$hw_yarpp->diagnostic_custom_templates()) {
    $template_option = hw_yarpp_get_option('template');
    if ($template_option !== false && $template_option !== 'thumbnails') {
        hw_yarpp_set_option('template', false);
    }
    $template_option = hw_yarpp_get_option('rss_template');
    if ($template_option !== false && $template_option !== 'thumbnails') {
        hw_yarpp_set_option('rss_template', false);
    }
}
/**
 * @since 3.3  Move version checking here, in PHP.
 */
if (current_user_can('update_plugins')) {
    $yarpp_version_info = $hw_yarpp->version_info();
    /*
     * These strings are not localizable, as long as the plugin data on wordpress.org cannot be.
     */
    $slug = 'yet-another-related-posts-plugin';
    $plugin_name = 'Yet Another Related Posts Plugin';
    $file = basename(HW_YARPP_DIR) . '/yarpp.php';
    if ($yarpp_version_info['result'] === 'new') {