Пример #1
0
function mtphr_dnt_initialize_settings()
{
    $settings = mtphr_dnt_general_settings();
    /* --------------------------------------------------------- */
    /* !Add the setting sections - 1.4.0 */
    /* --------------------------------------------------------- */
    add_settings_section('mtphr_dnt_general_settings_section', __('Ditty News Ticker settings', 'ditty-news-ticker'), false, 'mtphr_dnt_general_settings');
    /* --------------------------------------------------------- */
    /* !Add the settings - 1.4.0 */
    /* --------------------------------------------------------- */
    /* Visual Editor */
    $title = mtphr_dnt_settings_label(__('Visual Editor', 'ditty-news-ticker'), __('Use the visual editor to create tick contents', 'ditty-news-ticker'));
    add_settings_field('mtphr_dnt_general_settings_wysiwyg', $title, 'mtphr_dnt_general_settings_wysiwyg', 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings_section', array('settings' => $settings));
    /* Quick Edit Links */
    $title = mtphr_dnt_settings_label(__('Quick Edit Links', 'ditty-news-ticker'), __('Add quick edit links on the front-end of the site for editors and admins', 'ditty-news-ticker'));
    add_settings_field('mtphr_dnt_general_settings_edit_links', $title, 'mtphr_dnt_general_settings_edit_links', 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings_section', array('settings' => $settings));
    /* Custom CSS */
    $title = mtphr_dnt_settings_label(__('Custom CSS', 'ditty-news-ticker'), __('Add custom css to style your ticker without modifying any external files', 'ditty-news-ticker'));
    add_settings_field('mtphr_dnt_general_settings_css', $title, 'mtphr_dnt_general_settings_css', 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings_section', array('settings' => $settings));
    /* --------------------------------------------------------- */
    /* !Register the settings - 1.4.0 */
    /* --------------------------------------------------------- */
    if (false == get_option('mtphr_dnt_general_settings')) {
        add_option('mtphr_dnt_general_settings');
    }
    register_setting('mtphr_dnt_general_settings', 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings_sanitize');
}
Пример #2
0
 function mtphr_dnt_default_fields()
 {
     $settings = mtphr_dnt_general_settings();
     $values = mtphr_dnt_default_values();
     $fields = array('ticks' => array('heading' => __('Ticks', 'ditty-news-ticker'), 'description' => __('Add an unlimited number of ticks to your ticker', 'ditty-news-ticker'), 'help' => __('Use the \'+\' and \'x\' buttons on the right to add and delete ticks. Drag and drop the arrows on the left to re-order your ticks.', 'ditty-news-ticker'), 'type' => 'list', 'name' => '_mtphr_dnt_ticks', 'value' => $values['ticks'], 'fields' => array('tick' => array('heading' => __('Ticker text', 'ditty-news-ticker'), 'help' => __('Add the content of your tick. HTML and inline styles are supported.', 'ditty-news-ticker'), 'type' => isset($settings['wysiwyg']) && ($settings['wysiwyg'] == '1' || $settings['wysiwyg'] == 'on') ? 'wysiwyg' : 'textarea', 'placeholder' => __('Add your content here. HTML and inline styles are supported.', 'ditty-news-ticker'), 'rows' => 2), 'link' => array('heading' => __('Link', 'ditty-news-ticker'), 'help' => __('Wrap a link around your tick content. You can also add a link directly into your content.', 'ditty-news-ticker'), 'type' => 'text', 'placeholder' => __('Add a URL (optional)', 'ditty-news-ticker')), 'target' => array('heading' => __('Target', 'ditty-news-ticker'), 'help' => __('Set a target for your link.', 'ditty-news-ticker'), 'type' => 'select', 'options' => array('_self' => '_self', '_blank' => '_blank')), 'nofollow' => array('heading' => __('No Follow', 'ditty-news-ticker'), 'help' => __('Enabling this setting will add an attribute called \'nofollow\' to your link. This tells search engines to not follow this link.', 'ditty-news-ticker'), 'type' => 'checkbox', 'label' => __('Add "nofollow" to link', 'ditty-news-ticker')))), 'line_breaks' => array('heading' => __('Line breaks', 'ditty-news-ticker'), 'description' => __('Force line breaks on carriage returns (not used for wysiwyg editors)', 'ditty-news-ticker'), 'help' => __('Enabling this setting will create new lines for all carrige returns contained in your tick text', 'ditty-news-ticker'), 'type' => 'checkbox', 'name' => '_mtphr_dnt_line_breaks', 'value' => $values['line_breaks'], 'label' => __('Force line breaks', 'ditty-news-ticker')));
     return apply_filters('mtphr_dnt_default_fields', $fields, $values);
 }
Пример #3
0
function mtphr_dnt_tick_edit_link($id)
{
    if (current_user_can('edit_pages')) {
        $settings = mtphr_dnt_general_settings();
        if (isset($settings['edit_links']) && $settings['edit_links']) {
            echo '<a class="mtphr-dnt-edit-link" href="' . get_edit_post_link($id) . '">' . __('<i class="mtphr-dnt-icon-gear"></i> Edit ticker', 'ditty-news-ticker') . '</a>';
        }
    }
}
Пример #4
0
 function mtphr_dnt_default_render_metabox()
 {
     global $post;
     $settings = mtphr_dnt_general_settings();
     $line_breaks = get_post_meta($post->ID, '_mtphr_dnt_line_breaks', true);
     $ticks = get_post_meta($post->ID, '_mtphr_dnt_ticks', true);
     echo '<input type="hidden" name="mtphr_dnt_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />';
     echo '<table class="mtphr-dnt-table">';
     echo '<tr>';
     echo '<td class="mtphr-dnt-label">';
     echo '<label>' . __('Line breaks', 'ditty-news-ticker') . '</label>';
     echo '<small>' . __('Force line breaks on carriage returns', 'ditty-news-ticker') . '</small>';
     echo '</td>';
     echo '<td>';
     echo '<label><input type="checkbox" name="_mtphr_dnt_line_breaks" value="1" ' . checked('1', $line_breaks, false) . ' />' . __('Force line breaks', 'ditty-news-ticker') . '</label>';
     echo '</td>';
     echo '</tr>';
     echo '<tr>';
     echo '<td class="mtphr-dnt-label">';
     echo '<label>' . __('Ticks', 'ditty-news-ticker') . '</label>';
     echo '<small>' . __('Add an unlimited number of ticks to your ticker', 'ditty-news-ticker') . '</small>';
     echo '</td>';
     echo '<td>';
     echo '<table class="mtphr-dnt-list mtphr-dnt-default-list mtphr-dnt-advanced-list">';
     echo '<tr>';
     echo '<th class="mtphr-dnt-list-handle"></th>';
     $label = __('Ticker text', 'ditty-news-ticker');
     if ($settings['wysiwyg'] == '1') {
         $label .= '<div class="mtphr-dnt-notice">' . __('<strong>Notice:</strong> When using the WYSIWYG editor you must save your ticker after adding or re-arranging ticks.', 'ditty-news-ticker') . '</div>';
     }
     echo '<th>' . $label . '</th>';
     echo '<th>' . __('Link', 'ditty-news-ticker') . '</th>';
     echo '<th class="mtphr-dnt-default-target">' . __('Target', 'ditty-news-ticker') . '</th>';
     echo '<th class="mtphr-dnt-default-nofollow">' . __('NF', 'ditty-news-ticker') . '</th>';
     echo '<th class="mtphr-dnt-list-delete"></th>';
     echo '<th class="mtphr-dnt-list-add"></th>';
     echo '</tr>';
     if (is_array($ticks) && count($ticks) > 0) {
         foreach ($ticks as $i => $tick) {
             mtphr_dnt_render_default_tick($settings, $tick);
         }
     } else {
         mtphr_dnt_render_default_tick($settings);
     }
     echo '</table>';
     echo '</td>';
     echo '</tr>';
     echo '</table>';
 }