Layson
Forum Replies Created
-
Forum: Plugins
In reply to: [CMB2] 2018 Date Sorting Not WorkingWorked great! Now I just have to have a script run in the plugin update to change the current metadata.
Thanks!
Forum: Plugins
In reply to: [CMB2] 2018 Date Sorting Not WorkingCorrect it was a typo on my part when I posted to the forum. I checked my script and it is matching.
It is being saved using the text_date field that saves the data as 01/07/2018. I have checked this by displaying the selected date in the post and it shows all data.
I also tested and added a date form 2016 and it show up before the 2017 posts. Not sure what all is happening.
So as of right now its displaying the post by year going from oldest to newest but then in the months its being displayed within that year the newest month/day to the oldest.
Any thoughts? @tw2113
Forum: Plugins
In reply to: [CMB2] Category Metabox Echo Not DisplayingYou are correct. Sorry I missed that.
I updated my prefix to dc_tax_ and it works great.
Thanks for seeing that!
Forum: Plugins
In reply to: [CMB2] Category Metabox Echo Not DisplayingI have tried a couple of different things. This echos out the id but code still not working. Any chance you could give me any more detailed example.
<?php $term_id = get_queried_object()->term_id; $avatar = get_term_meta( $term_id, 'dc_tax_avatar', true ); if(empty($avatar)){ echo 'still doesnt work'; } else { echo '<span style="color:#fff;">'. $avatar .'</span>'; } ?>
I have also tried this:
<?php get_term_meta(get_queried_object()->term_id, 'dc_tax_avatar', true ); ?>
Thanks for your help on this- This reply was modified 7 years, 7 months ago by Layson.
Forum: Plugins
In reply to: [CMB2] Displaying Data in ShordcodeIts the simple things in life. lol
Thanks Justin for the fast reply. That worked!
G
- This reply was modified 7 years, 7 months ago by Layson.
Forum: Plugins
In reply to: [CMB2] Adding Custom HTML to MetaboxThanks Justin just what I was looking for!
G
Forum: Plugins
In reply to: [CMB2] Echo Data from Options Page in Custom Post Type PluginHere is the final update on what all was happening. Thanks to Michael for the suggestion. I set up my plugin so that it loads scripts for “Front End” + “Admin” and then another that just loads the scripts on the “Admin”. I was originally loading the CMB2 Options script on jut the admin side so nothing was being loaded on the site. I fixed this and now everything works great.
Also for future note. This code also works to echo out any of the fields:
<?php echo dcoptions_get_option( 'test_text' ) ?>
Awesome product and support!
Forum: Plugins
In reply to: [CMB2] Echo Data from Options Page in Custom Post Type PluginI didn’t change a thing and I am getting this:
Fatal error: Uncaught Error: Call to undefined function dcoptions_get_option()
and was using this to display on my template page:
<?php $select = michael_admin_init(); echo $select; ?>
Any thoughts?
I guess I should give more of a description of what all I am using it for.
I am using the options page to control the css on my archive, tax and single page via the class…. So what I did before in CMB2 for my metabox via the custom post type was the following:
.plyr--video .plyr__controls button.tab-focus:focus, .plyr--video .plyr__controls button:hover { background: <?php echo get_post_meta( $post->ID, 'dc_sermons_dc_color', true ); ?> !important; }
This worked great for custom changes like player colors on each custom post type that is different or it displays the default.
Now what I am needing is the ability for them to change the colors on the archive page or global colors like links, titles or button colors. That is why I am trying to echo the option field to my css to change the colors and so on.
Hope this helps out more what all I am doing and maybe will show where my thoughts are.
Again thanks for your help!
GForum: Plugins
In reply to: [CMB2] Echo Data from Options Page in Custom Post Type PluginI did know that the code snip was for ID and for the meta only. I didn’t know if there was a similar code to echo my options.
here is my option page:
<?php /** * CMB2 Theme Options * @version 0.1.0 */ class DCOptions_Admin { /** * Option key, and option page slug * @var string */ protected $key = 'dcoptions_options'; /** * Options page metabox id * @var string */ protected $metabox_id = 'dcoptions_option_metabox'; /** * Options Page title * @var string */ protected $title = ''; /** * Options Page hook * @var string */ protected $options_page = ''; /** * Holds an instance of the object * * @var Myprefix_Admin */ protected static $instance = null; /** * Returns the running object * * @return Myprefix_Admin */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); self::$instance->hooks(); } return self::$instance; } /** * Constructor * @since 0.1.0 */ protected function __construct() { // Set our title $this->title = __( 'Hub Options', 'dcoptions' ); } /** * Initiate our hooks * @since 0.1.0 */ public function hooks() { add_action( 'admin_init', array( $this, 'init' ) ); add_action( 'admin_menu', array( $this, 'add_options_page' ) ); add_action( 'cmb2_admin_init', array( $this, 'add_options_page_metabox' ) ); } /** * Register our setting to WP * @since 0.1.0 */ public function init() { register_setting( $this->key, $this->key ); } /** * Add menu options page * @since 0.1.0 */ public function add_options_page() { $this->options_page = add_menu_page( $this->title, $this->title, 'manage_options', $this->key, array( $this, 'admin_page_display' ) ); // Include CMB CSS in the head to avoid FOUC add_action( "admin_print_styles-{$this->options_page}", array( 'CMB2_hookup', 'enqueue_cmb_css' ) ); } /** * Admin page markup. Mostly handled by CMB2 * @since 0.1.0 */ public function admin_page_display() { ?> <div class="wrap cmb2-options-page <?php echo $this->key; ?>"> <h2><?php echo esc_html( get_admin_page_title() ); ?></h2> <?php cmb2_metabox_form( $this->metabox_id, $this->key ); ?> </div> <?php } /** * Add the options metabox to the array of metaboxes * @since 0.1.0 */ function add_options_page_metabox() { // hook in our save notices add_action( "cmb2_save_options-page_fields_{$this->metabox_id}", array( $this, 'settings_notices' ), 10, 2 ); $cmb = new_cmb2_box( array( 'id' => $this->metabox_id, 'hookup' => false, 'cmb_styles' => false, 'show_on' => array( // These are important, don't remove 'key' => 'options-page', 'value' => array( $this->key, ) ), ) ); // Set our CMB2 fields $cmb->add_field( array( 'name' => __( 'Test Text', 'dcoptions' ), 'desc' => __( 'field description (optional)', 'dcoptions' ), 'id' => 'test_text', 'type' => 'text', 'default' => 'Default Text', ) ); $cmb->add_field( array( 'name' => __( 'Test Color Picker', 'dcoptions' ), 'desc' => __( 'field description (optional)', 'dcoptions' ), 'id' => 'test_colorpicker', 'type' => 'colorpicker', 'default' => '#bada55', ) ); } /** * Register settings notices for display * * @since 0.1.0 * @param int $object_id Option key * @param array $updated Array of updated fields * @return void */ public function settings_notices( $object_id, $updated ) { if ( $object_id !== $this->key || empty( $updated ) ) { return; } add_settings_error( $this->key . '-notices', '', __( 'Settings updated.', 'myprefix' ), 'updated' ); settings_errors( $this->key . '-notices' ); } /** * Public getter method for retrieving protected/private variables * @since 0.1.0 * @param string $field Field to retrieve * @return mixed Field value or exception is thrown */ public function __get( $field ) { // Allowed fields to retrieve if ( in_array( $field, array( 'key', 'metabox_id', 'title', 'options_page' ), true ) ) { return $this->{$field}; } throw new Exception( 'Invalid property: ' . $field ); } } /** * Helper function to get/return the Myprefix_Admin object * @since 0.1.0 * @return Myprefix_Admin object */ function dcoptions_admin() { return DCOptions_Admin::get_instance(); } /** * Wrapper function around cmb2_get_option * @since 0.1.0 * @param string $key Options array key * @param mixed $default Optional default value * @return mixed Option value */ function dcoptions_get_option( $key = '', $default = false ) { if ( function_exists( 'cmb2_get_option' ) ) { // Use cmb2_get_option as it passes through some key filters. return cmb2_get_option( dcoptions_admin()->key, $key, $default ); } // Fallback to get_option if CMB2 is not loaded yet. $opts = get_option( dcoptions_admin()->key, $default ); $val = $default; if ( 'all' == $key ) { $val = $opts; } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { $val = $opts[ $key ]; } return $val; } // Get it started dcoptions_admin();
I just copied the template as a starting point and changed up the myprefix.
I have changed back to the default fields just because i was having issues and didn’t know if it was my fields I created. I am assuming that all I would have to do then is change out the ID with the new field ID to display then after the given code?
Also thanks for getting back so quickly I am on a deadline to produce this plugin.
G
Forum: Plugins
In reply to: [CMB2] Echo Data from Options Page in Custom Post Type PluginThanks for the comment. I have tried this before and spent the last two hours trying to get it to work again and still doesn’t work. It echos out null for me. And any other try being listed above keeps echoing out the page html.
Anyone have a solution similar to
<?php echo get_post_meta( $post->ID, 'dc_sermons_dc_color', true ); ?>
that I have been using to echo standard metadata from CMB2?
Forum: Plugins
In reply to: [YITH Essential Kit for WooCommerce #1] YITH Wishlist Shortcode Fatal ErrorI am having the same problem here also.
Forum: Plugins
In reply to: [Free Downloads WooCommerce] Conflict with Divi PluginJust sent email thanks for your help!
Forum: Plugins
In reply to: [Free Downloads WooCommerce] Conflict with Divi PluginOn non digital products the cart button shows up fine using the following plugin.
https://elegantmarketplace.com/downloads/woo-layout-injector/
Also any other download now plugin works fine with the plugin above. Just yours doesn’t. I contacted the author of that plugin and he said that it just adds the add to cart button to the page only. Just like if I created a custom simple product page would. So as long as your replaces the add to cart button it should work okay.
That is why I’m contacting you to try and figure out whats up…
Thanks for your help.
Forum: Plugins
In reply to: [Free Downloads WooCommerce] Conflict with Divi PluginYes that is correct about the buttons. This is the plugin that is giving it problems.
https://elegantmarketplace.com/downloads/woo-layout-injector/
What wired is that it pulls the add to cart and the other download now buttons correctly on the pages but not yours.
I tried it on the shop page and it doesn’t work until I turn off the plugin that I put above. I contacted that plugin author and he insured me that if the plugin just adds the add to cart button and it should work as long as your plugin replaces the add to cart button.
That is why I’m contacting you to see if it is something that you can find on your end that doesn’t work right.
Forum: Fixing WordPress
In reply to: How to change the text labels in user/pass box on login pageIf you use the following code in your themes functions.php and replace the “Your Custom Text” with whatever you are wanting.
add_filter( 'gettext', 'register_text' ); add_filter( 'ngettext', 'register_text' ); function register_text( $translated ) { $translated = str_ireplace( 'Username or Email Address', 'Your Custom Text', $translated ); return $translated; }
- This reply was modified 8 years, 1 month ago by Layson.