mirror of
https://github.com/10h30/full-screen-morphing-search.git
synced 2026-07-11 18:46:04 +09:00
Search Form Text & Icons
This commit is contained in:
@@ -35,7 +35,7 @@ function fsmsp_customize_preview_js() {
|
||||
'fsmsp_article_icon' => '<img src="' . esc_url( plugins_url( 'assets/img/article.png', __FILE__ ) ) . '">',
|
||||
'fsmsp_category_icon' => '<img src="' . esc_url( plugins_url( 'assets/img/category.png', __FILE__ ) ) . '">',
|
||||
'fsmsp_tag_icon' => '<img src="' . esc_url( plugins_url( 'assets/img/tag.png', __FILE__ ) ) . '">',
|
||||
'fsmsp_placeholder_text' => esc_attr( 'Search …' ),
|
||||
'fsmsp_placeholder_text' => esc_attr( 'Search…' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -382,5 +382,323 @@ function full_screen_morphing_search_customize_register( $wp_customize ) {
|
||||
)
|
||||
);
|
||||
|
||||
// Add Search Form Section.
|
||||
$wp_customize->add_section(
|
||||
'fsmsp_search_form',
|
||||
array(
|
||||
'title' => __( 'FSMS Search Form', 'full-screen-morphing-search' ),
|
||||
'priority' => 10,
|
||||
'panel' => 'fsmsp_panel',
|
||||
)
|
||||
);
|
||||
|
||||
// ==========================
|
||||
// = FSMS Search Form Text. =
|
||||
// ==========================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_search_form_text]',
|
||||
array(
|
||||
'default' => '',
|
||||
'sanitize_callback' => 'wp_filter_nohtml_kses', // Strips all HTML from a text string.
|
||||
'capability' => 'edit_theme_options',
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'fsmsp_options[fsmsp_search_form_text]',
|
||||
array(
|
||||
'label' => __( 'FSMS Search Form Text', 'full-screen-morphing-search' ),
|
||||
'description' => esc_attr__( 'Change the search form text. If leaved blank, it will return to original value !', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_search_form',
|
||||
'settings' => 'fsmsp_options[fsmsp_search_form_text]',
|
||||
'type' => 'text',
|
||||
'input_attrs' => array(
|
||||
'placeholder' => __( 'Search…', 'full-screen-morphing-search' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Add Icons Section.
|
||||
$wp_customize->add_section(
|
||||
'fsmsp_icons',
|
||||
array(
|
||||
'title' => __( 'FSMS Icons', 'full-screen-morphing-search' ),
|
||||
'priority' => 15,
|
||||
'panel' => 'fsmsp_panel',
|
||||
)
|
||||
);
|
||||
|
||||
// ======================
|
||||
// = FSMS Article Icon. =
|
||||
// ======================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_article_icon]',
|
||||
array(
|
||||
'default' => '',
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'fsmsp_options[fsmsp_article_icon]',
|
||||
array(
|
||||
'label' => __( 'FSMS Article Icon', 'full-screen-morphing-search' ),
|
||||
'description' => esc_attr__( 'Change the article icon.', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_article_icon]',
|
||||
'button_labels' => array(
|
||||
'select' => __( 'Select Article Icon' ),
|
||||
'change' => __( 'Change Article Icon' ),
|
||||
'remove' => __( 'Remove' ),
|
||||
'frame_title' => __( 'Select Article Icon' ),
|
||||
'frame_button' => __( 'Choose Article Icon' ),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_article_icon]',
|
||||
array(
|
||||
'selector' => 'div.dummy-media-object a.fsmsp-article-link',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_article_icon]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_article_icon',
|
||||
)
|
||||
);
|
||||
|
||||
// ====================================
|
||||
// = FSMS Article Icon/Image Classes. =
|
||||
// ====================================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_article_i_classes]',
|
||||
array(
|
||||
'default' => true,
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'fsmsp_options[fsmsp_article_i_classes]',
|
||||
array(
|
||||
'label' => __( 'Article Icon/Image Round or Not ?!', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_article_i_classes]',
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_article_i_classes]',
|
||||
array(
|
||||
'selector' => 'div.dummy-media-object a.fsmsp-article-link',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_article_i_classes]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_article_icon',
|
||||
)
|
||||
);
|
||||
|
||||
// =======================
|
||||
// = FSMS Category Icon. =
|
||||
// =======================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_category_icon]',
|
||||
array(
|
||||
'default' => '',
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'fsmsp_options[fsmsp_category_icon]',
|
||||
array(
|
||||
'label' => __( 'FSMS Category Icon', 'full-screen-morphing-search' ),
|
||||
'description' => esc_attr__( 'Change the category icon.', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_category_icon]',
|
||||
'button_labels' => array(
|
||||
'select' => __( 'Select Category Icon' ),
|
||||
'change' => __( 'Change Category Icon' ),
|
||||
'remove' => __( 'Remove' ),
|
||||
'frame_title' => __( 'Select Category Icon' ),
|
||||
'frame_button' => __( 'Choose Category Icon' ),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_category_icon]',
|
||||
array(
|
||||
'selector' => 'span.fsmsp-category-image',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_category_icon]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_category_icon',
|
||||
)
|
||||
);
|
||||
|
||||
// =====================================
|
||||
// = FSMS Category Icon/Image Classes. =
|
||||
// =====================================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_category_i_classes]',
|
||||
array(
|
||||
'default' => true,
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'fsmsp_options[fsmsp_category_i_classes]',
|
||||
array(
|
||||
'label' => __( 'Category Icon/Image Round or Not ?!', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_category_i_classes]',
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_category_i_classes]',
|
||||
array(
|
||||
'selector' => 'span.fsmsp-category-image',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_category_i_classes]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_category_icon',
|
||||
)
|
||||
);
|
||||
|
||||
// ==================
|
||||
// = FSMS Tag Icon. =
|
||||
// ==================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_tag_icon]',
|
||||
array(
|
||||
'default' => '',
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'fsmsp_options[fsmsp_tag_icon]',
|
||||
array(
|
||||
'label' => __( 'FSMS Tag Icon', 'full-screen-morphing-search' ),
|
||||
'description' => esc_attr__( 'Change the tag icon.', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_tag_icon]',
|
||||
'button_labels' => array(
|
||||
'select' => __( 'Select Tag Icon' ),
|
||||
'change' => __( 'Change Tag Icon' ),
|
||||
'remove' => __( 'Remove' ),
|
||||
'frame_title' => __( 'Select Tag Icon' ),
|
||||
'frame_button' => __( 'Choose Tag Icon' ),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_tag_icon]',
|
||||
array(
|
||||
'selector' => 'span.fsmsp-tag-image',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_tag_icon]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_tag_icon',
|
||||
)
|
||||
);
|
||||
|
||||
// ================================
|
||||
// = FSMS Tag Icon/Image Classes. =
|
||||
// ================================
|
||||
$wp_customize->add_setting(
|
||||
'fsmsp_options[fsmsp_tag_i_classes]',
|
||||
array(
|
||||
'default' => true,
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'fsmsp_options[fsmsp_tag_i_classes]',
|
||||
array(
|
||||
'label' => __( 'Tag Icon/Image Round or Not ?!', 'full-screen-morphing-search' ),
|
||||
'section' => 'fsmsp_icons',
|
||||
'settings' => 'fsmsp_options[fsmsp_tag_i_classes]',
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'fsmsp_options[fsmsp_tag_i_classes]',
|
||||
array(
|
||||
'selector' => 'span.fsmsp-tag-image',
|
||||
'settings' => array( 'fsmsp_options[fsmsp_tag_i_classes]' ),
|
||||
'render_callback' => 'full_screen_morphing_search_tag_icon',
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
add_action( 'customize_register', 'full_screen_morphing_search_customize_register' );
|
||||
|
||||
/**
|
||||
* Render article icon for the selective refresh partial.
|
||||
*/
|
||||
function full_screen_morphing_search_article_icon() {
|
||||
$image_url = get_option( 'fsmsp_options' )['fsmsp_article_icon'];
|
||||
$attachment_id = attachment_url_to_postid( $image_url ); // Tries to convert an attachment URL into a post ID.
|
||||
$article_i_classes = get_option( 'fsmsp_options' )['fsmsp_article_i_classes'];
|
||||
$classes;
|
||||
if ( ! empty( $article_i_classes ) ) {
|
||||
$classes = 'round fsmsp-article-icon';
|
||||
} else {
|
||||
$classes = 'fsmsp-article-icon';
|
||||
}
|
||||
echo wp_get_attachment_image( $attachment_id, 'thumbnail', '', array( 'class' => $classes ) ); // Get an HTML img element representing an image attachment.
|
||||
}
|
||||
|
||||
/**
|
||||
* Render category icon for the selective refresh partial.
|
||||
*/
|
||||
function full_screen_morphing_search_category_icon() {
|
||||
$imagecat_url = get_option( 'fsmsp_options' )['fsmsp_category_icon'];
|
||||
$attachmentcat_id = attachment_url_to_postid( $imagecat_url );
|
||||
$category_i_classes = get_option( 'fsmsp_options' )['fsmsp_category_i_classes'];
|
||||
$classes;
|
||||
if ( ! empty( $category_i_classes ) ) {
|
||||
$classes = 'round fsmsp-category-icon';
|
||||
} else {
|
||||
$classes = 'fsmsp-category-icon';
|
||||
}
|
||||
echo wp_get_attachment_image( $attachmentcat_id, 'thumbnail', '', array( 'class' => $classes ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render tag icon for the selective refresh partial.
|
||||
*/
|
||||
function full_screen_morphing_search_tag_icon() {
|
||||
$imagetag_url = get_option( 'fsmsp_options' )['fsmsp_tag_icon'];
|
||||
$attachmenttag_id = attachment_url_to_postid( $imagetag_url );
|
||||
$tag_i_classes = get_option( 'fsmsp_options' )['fsmsp_tag_i_classes'];
|
||||
$classes;
|
||||
if ( ! empty( $tag_i_classes ) ) {
|
||||
$classes = 'round fsmsp-tag-icon';
|
||||
} else {
|
||||
$classes = 'fsmsp-tag-icon';
|
||||
}
|
||||
echo wp_get_attachment_image( $attachmenttag_id, 'thumbnail', '', array( 'class' => $classes ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user