shatner_label = get_option('shatner_label', "Name your own price"); add_action('wp_enqueue_scripts', function () { wp_enqueue_script('shatner', plugins_url('/shatner.js',__FILE__), array('jquery') ); }); if ( is_admin() ){ // admin actions $this->init_form_fields(); add_action( 'admin_menu', array($this, 'add_shatner_menu' )); add_action( 'admin_init', array($this, 'admin_init' )); add_action('woocommerce_before_calculate_totals', array($this, 'add_custom_price' )); add_action('woocommerce_product_options_pricing', array($this, 'add_donation_radio')); add_action('save_post', array($this, 'set_named_price')); } else { if(get_option('use_shatner_templates', 1 ) == 1) { add_filter('woocommerce_locate_template', array($this, 'template_override'),10,3); add_filter('woocommerce_loop_add_to_cart_link', array($this, 'remove_link'),10); } add_action('woocommerce_product_options_pricing', array($this, 'add_donation_radio')); add_action('save_post', array($this, 'set_named_price')); add_action('woocommerce_add_to_cart', array($this, 'add_to_cart_hook')); add_action('woocommerce_before_calculate_totals', array($this, 'add_custom_price' )); add_action('init', array($this, 'init_css')); } } public function remove_link($link) { global $post; $post = get_post_meta($post->ID, '_own_price', true); if ($post === 'yes') return ''; return $link; } public function add_shatner_menu() { add_options_page( 'Shatner Plugin Settings', 'Shatner Settings', 'manage_options', 'shatner_plugin', array($this, 'shatner_plugin_settings_page') ); } public function shatner_plugin_settings_page() { include(sprintf("%s/templates/settings.php", dirname(__FILE__))); } /** * hook into WP's admin_init action hook */ public function admin_init() { // add your settings section add_settings_section( 'wp_plugin_template-section_shatner', 'Shatner Plugin Template Settings', array($this, 'settings_section_shatner_plugin_template'), 'wp_plugin_template_shatner' ); foreach($this->form_fields as $setting) { // register your plugin's settings register_setting('wp_plugin_template-group-shatner', $setting['title']); // add your setting's fields add_settings_field( $setting['title'], $setting['description'], array(&$this, 'settings_field_input_'. $setting['type']), 'wp_plugin_template_shatner', 'wp_plugin_template-section_shatner', array( 'field' => $setting['title'] ) ); } } // END public static function activate public function init_form_fields() { $this->form_fields = array( array( 'type' => 'text', 'title' => esc_html__('shatner_label', 'woothemes'), 'description' => esc_html__('Shatner Label', 'woothemes'), 'default' => esc_html__('Name your own price', 'woothemes') ), array( 'type' => 'radio_button', 'title' => esc_html__('use_shatner_templates', 'woothemes'), 'description' => esc_html__('Shatner Templates override pricing, disable if you want to customize using your theme', 'woothemes'), 'default' => esc_html__('1', 'woothemes') ) ); } public function settings_section_shatner_plugin_template() { // Think of this as help text for the section. echo 'These settings set values for Shatner'; } /** * This function provides text inputs for settings fields */ public function settings_field_input_text($args) { // Get the field name from the $args array $field = $args['field']; // Get the value of this setting $value = get_option($field); // echo a proper input type="text" echo sprintf('', $field, $field, $value); } // END public function settings_field_input_text($args) /** * This function provides text inputs for settings fields */ public function settings_field_input_radio_button($args) { // Get the field name from the $args array $field = $args['field']; // Get the value of this setting $value = get_option($field); $html = ' '; $html .= '
'; $html .= ' '; $html .= ' '; echo $html; } // END public function settings_field_input_radio($args) public function template_override($template, $template_name, $template_path ) { // Modification: Get the template from this plugin, if it exists $plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ). '/templates/'; if ( file_exists( $plugin_path . $template_name ) ) { $template = $plugin_path . $template_name; return $template; } return $template; } public function init_css() { wp_register_style('donation_css', plugins_url('custom_styles.css',__FILE__ ), false, '1.0.1', 'all'); wp_enqueue_style( 'donation_css' ); } public function add_to_cart_hook($key) { global $woocommerce; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) { if(!get_post_meta($values['product_id'], '_own_price', true ) || get_post_meta($values['product_id'], '_own_price', true ) === 'no') { $values['data']->set_price($_POST['price']); continue; } $thousands_sep = wp_specialchars_decode( stripslashes( get_option( 'woocommerce_price_thousand_sep' ) ), ENT_QUOTES ); $decimal_sep = stripslashes( get_option( 'woocommerce_price_decimal_sep' ) ); $_POST['price'] = str_replace($thousands_sep, '', $_POST['price']); $_POST['price'] = str_replace($decimal_sep, '.', $_POST['price']); $_POST['price'] = wc_format_decimal($_POST['price']); if($cart_item_key == $key) { $values['data']->set_price($_POST['price']); $woocommerce->session->__set($key .'_named_price', $_POST['price']); } } return $key; } public function set_named_price($post) { if(isset($_POST['_own_price'])){ if(!get_post_meta($_POST['post_ID'], '_own_price', true )){ add_post_meta($_POST['post_ID'], '_own_price', $_POST['_own_price']); } else { update_post_meta($_POST['post_ID'], '_own_price', $_POST['_own_price']); } } if(isset($_POST['_own_price_enforce_minimum'])){ if(!get_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', true )){ add_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', $_POST['_own_price_enforce_minimum']); } else { update_post_meta($_POST['post_ID'], '_own_price_enforce_minimum', $_POST['_own_price_enforce_minimum']); } } } public function add_donation_radio($content) { global $post; woocommerce_wp_radio(array( 'id' => '_own_price', 'class' => 'wc_own_price short', 'label' => esc_html__( 'Name your own price', 'woocommerce' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ) ) ); woocommerce_wp_radio(array( 'id' => '_own_price_enforce_minimum', 'class' => 'wc_own_price_e short', 'label' => esc_html__( 'Enforce "Regular price" as the minimum price', 'woocommerce' ), 'options' => array( 'yes' => 'Yes', 'no' => 'No', ) ) ); } public function add_custom_price( $cart_object ) { global $woocommerce; foreach ( $cart_object->cart_contents as $key => $value ) { if(!get_post_meta($value['product_id'], '_own_price', true ) || get_post_meta($value['product_id'], '_own_price', true ) === 'no') { continue; } $named_price = $woocommerce->session->__get($key .'_named_price'); if($named_price) { $product = $value['data']; $product->set_price( $named_price ); } } } } new SV_WC_Donation(); admin – REACH Foundation https://reachfoundation.life Just another WordPress site Fri, 31 Oct 2025 00:30:59 +0000 en hourly 1 https://wordpress.org/?v=7.0 Hello world! https://reachfoundation.life/uncategorized/hello-world/ https://reachfoundation.life/uncategorized/hello-world/#comments Fri, 31 Oct 2025 00:30:59 +0000 http://reachfoundation.life/?p=1 Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

]]>
https://reachfoundation.life/uncategorized/hello-world/feed/ 1
Post With A Video https://reachfoundation.life/news/post-with-a-video/ https://reachfoundation.life/news/post-with-a-video/#respond Fri, 05 Sep 2014 21:10:55 +0000 http://demo.organizedthemes.com/grassroots/?p=61 This post shows you what a video looks like in the midst of your content. Did you know that adding a video to a page or post is trivially easy? All you have to do is place the URL to the video on its own line and voila, WordPress will grab the video for you and display it.

Grassroots even takes that one notch further and makes your video responsive. Automatically. You don’t have to do anything else. Piece of cake right?

]]>
https://reachfoundation.life/news/post-with-a-video/feed/ 0
Post With A Gallery https://reachfoundation.life/news/post-with-a-gallery/ https://reachfoundation.life/news/post-with-a-gallery/#respond Fri, 05 Sep 2014 20:34:52 +0000 http://demo.organizedthemes.com/grassroots/?p=54 This post features a lightbox gallery. You can easily create a gallery in WordPress and end up with the great result you see here. Grassroots takes this a step further by including a nice lightbox effect that will enlarge your images just like you see here.

It’s easy to do and looks absolutely great too!

]]>
https://reachfoundation.life/news/post-with-a-gallery/feed/ 0
Helping Kids https://reachfoundation.life/news/helping-kids/ https://reachfoundation.life/news/helping-kids/#respond Fri, 05 Sep 2014 20:27:34 +0000 http://demo.organizedthemes.com/grassroots/?p=52 Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Curabitur blandit tempus porttitor.

Nullam id dolor id nibh ultricies vehicula ut id elit. Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Vestibulum id ligula porta felis euismod semper.

Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Maecenas sed diam eget risus varius blandit sit amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed posuere consectetur est at lobortis. Maecenas sed diam eget risus varius blandit sit amet non magna. Etiam porta sem malesuada magna mollis euismod.

]]>
https://reachfoundation.life/news/helping-kids/feed/ 0
No Sidebar https://reachfoundation.life/features/no-sidebar/ https://reachfoundation.life/features/no-sidebar/#respond Thu, 04 Sep 2014 14:15:35 +0000 http://demo.organizedthemes.com/grassroots/?p=89 Grassroots comes with three layout options for pages/posts: left hand sidebar with right hand content, left hand content with right hand sidebar and a no sidebar, full width content layout.

This page shows what it looks like to have no sidebar (full-width content). You can set the same layout for all pages/posts in the theme options. The setting can be overwritten on individual pages as you need to.

]]>
https://reachfoundation.life/features/no-sidebar/feed/ 0
No Sidebar https://reachfoundation.life/features/no-sidebar/ https://reachfoundation.life/features/no-sidebar/#respond Thu, 04 Sep 2014 14:15:35 +0000 http://demo.organizedthemes.com/grassroots/?p=89 Grassroots comes with three layout options for pages/posts: left hand sidebar with right hand content, left hand content with right hand sidebar and a no sidebar, full width content layout.

This page shows what it looks like to have no sidebar (full-width content). You can set the same layout for all pages/posts in the theme options. The setting can be overwritten on individual pages as you need to.

]]>
https://reachfoundation.life/features/no-sidebar/feed/ 0
Right Hand Sidebar https://reachfoundation.life/features/right-hand-sidebar/ https://reachfoundation.life/features/right-hand-sidebar/#respond Thu, 04 Sep 2014 14:15:01 +0000 http://demo.organizedthemes.com/grassroots/?p=88 Grassroots comes with three layout options for pages/posts: left hand sidebar with right hand content, left hand content with right hand sidebar and a no sidebar, full width content layout.

This page shows what it looks like to have a sidebar on the right hand side. You can set the same layout for all pages/posts in the theme options. The setting can be overwritten on individual pages as you need to.

]]>
https://reachfoundation.life/features/right-hand-sidebar/feed/ 0
Left Hand Sidebar https://reachfoundation.life/features/left-hand-sidebar/ https://reachfoundation.life/features/left-hand-sidebar/#respond Thu, 04 Sep 2014 14:12:44 +0000 http://demo.organizedthemes.com/grassroots/?p=87 Grassroots comes with three layout options for pages/posts: left hand sidebar with right hand content, left hand content with right hand sidebar and a no sidebar, full width content layout.

This page shows what it looks like to have a sidebar on the left hand side. You can set the same layout for all pages/posts in the theme options. The setting can be overwritten on individual pages as you need to.

]]>
https://reachfoundation.life/features/left-hand-sidebar/feed/ 0
A Post With Comments https://reachfoundation.life/features/a-post-with-comments/ https://reachfoundation.life/features/a-post-with-comments/#comments Wed, 03 Sep 2014 16:23:20 +0000 http://demo.organizedthemes.com/grassroots/?p=95 Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Nullam quis risus eget urna mollis ornare vel eu leo.

Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Maecenas sed diam eget risus varius blandit sit amet non magna.

]]>
https://reachfoundation.life/features/a-post-with-comments/feed/ 5
A Post With Comments https://reachfoundation.life/features/a-post-with-comments/ https://reachfoundation.life/features/a-post-with-comments/#comments Wed, 03 Sep 2014 16:23:20 +0000 http://demo.organizedthemes.com/grassroots/?p=95 Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Nullam quis risus eget urna mollis ornare vel eu leo.

Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Maecenas sed diam eget risus varius blandit sit amet non magna.

]]>
https://reachfoundation.life/features/a-post-with-comments/feed/ 5