changes to blocks and styles

This commit is contained in:
Jeremy Rangel
2024-12-27 22:56:39 -08:00
parent 93cc7be3bf
commit 462cffdddc
39 changed files with 959 additions and 228 deletions

View File

@ -115,6 +115,15 @@ function lcp_register_settings() {
'lcp_theme_settings_section' // Section where this field belongs
);
add_settings_field(
'enable_highlight_to_share', // Field ID
'Enable Highlight-to-Share', // Field title
'lcp_enable_highlight_to_share', // Field callback function
'lcp_theme_settings_page', // Page where this field appears
'lcp_theme_settings_section' // Section where this field belongs
);
// Add fields for custom breakpoints
add_settings_field(
'mobile_breakpoint', // Field ID
@ -176,7 +185,7 @@ function lcp_inject_breakpoints_to_frontend() {
}
</style>";
}
add_action('wp_head', 'lcp_inject_breakpoints_to_frontend',5);
add_action('wp_head', 'lcp_inject_breakpoints_to_frontend');
@ -191,6 +200,15 @@ function lcp_enable_key_points_meta_field() {
}
function lcp_enable_highlight_to_share() {
// Retrieve current value for 'enable_highlight_to_share'
$options = get_option( 'lcp_theme_settings', array() );
$checked = isset( $options['enable_highlight_to_share'] ) ? $options['enable_highlight_to_share'] : false;
// Output the checkbox
echo '<input type="checkbox" name="lcp_theme_settings[enable_highlight_to_share]" value="1" ' . checked( $checked, 1, false ) . ' />';
}
@ -327,3 +345,27 @@ function render_lcp_theme_settings_page() {
// Hooks
function highlight_to_share_popup() {
echo "
<div class=\"popup\" id=\"popup\">
<p>Hey there! Share this:</p>
<a href=\"#\" id=\"facebook-share\">Facebook</a> |
<a href=\"#\" id=\"twitter-share\">Twitter/X</a>
</div>
";
}
function lcp_wp_head_hooks(){
// Define lcp_theme_settings array from wp_options
$options = get_option('lcp_theme_settings', array());
// Echo highlight-to-share markup and enqueue javascript
// Highlight-to-share css is already in style.css
if ( isset($options['enable_highlight_to_share']) && $options['enable_highlight_to_share'] ) {
highlight_to_share_popup();
wp_enqueue_script( 'lcp-highlight-to-share', get_template_directory_uri() . '/assets/js/highlight-to-share.js', array(), null, true );
}
}
add_action('wp_head', 'lcp_wp_head_hooks');