I seen many similar questions but no solution. I am trying to make yamm3 work with Wordpress.
I know there is plugins but they are extremely bloated.
I think it should be very simple just using a custom metabox.
This example adds a metabox but only allows links.
http://pastebin.com/hj1cxYQg
Here is the basic function:
/* Mega Menu */
function mynav_add_custom_box() {
add_meta_box(
'add-mynav',
'Mega Menu',
'mynav_show_custom_box',
'nav-menus',
'side',
'default');
}
add_action( 'admin_init', 'mynav_add_custom_box' );
//display nav menu meta box
function mynav_show_custom_box() {
// code to create mega menu
?>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
<span class="spinner"></span>
</span>
</p>
<?php
}
Metabox options:
The first option I would have would be 'how many columns?' using
bootstrap grid system for its width (up to 5).
The second option, you will choose to add menu item(s)/image(s) in the column(s) or use html w/builtin wp editor.
The li that has the mega menu dropdown should have a wrap div with class 'yamm-content', that is the only thing that makes yamm3 structure different.
Related
I have registered a new submenu under WooCommerce. What I am looking for now is to load WooCommerce admin style css on that page. So I can just use WooComerce css classes and id to make it looks like the Orders Page.
Here is my code to register new setting page.
add_submenu_page(
'woocommerce', __('My Page Title', 'text-domain'), __('My Page Title', 'text-domain'), 'manage_options', 'my-custom-slug', array($this, 'my_custom_Page')
);
Here is my code to render my setting page elements.
public function my_custom_Page(){
?>
<div class="wrap">
<div id="root">
<div class="woocommerce-layout">
<div class="woocommerce-layout__header">
<div class="woocommerce-layout__header-wrapper">
<h1 class="woocommerce-layout__header-heading">My Custom Page</h1>
</div>
</div>
</div>
</div>
</div>
<?php
}
I am trying to find a solution to load WooCommerce admin pages css and JS into my custom admin page under WooCommerce.
To use WooCommerce custom admin css on your custom settings page add this code to the same file that add_submenu_page() code resides.
function random_add_woocommerce_admin_css() {
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css');
}
add_action( 'admin_enqueue_scripts', 'random_add_woocommerce_admin_css' );
I need to translate Choose File & No file chosen to another language (Japanese).
The following code is from acf field.
I looked into the code but there are no Choose File & No file chosen.
Would you please let me know how to translate them in this case?
<div class="acf-input">
<div class="acf-file-uploader" data-library="all" data-mime_types="" data-uploader="basic">
<input type="hidden" name="acf[field_60bc51d8898c5]" value="" data-name="id"> <div class="show-if-value file-wrap">
<div class="file-icon">
<img data-name="icon" src="" alt="">
</div>
<div class="file-info">
<p>
<strong data-name="title"></strong>
</p>
<p>
<strong>File name:</strong>
<a data-name="filename" href="" target="_blank"></a>
</p>
<p>
<strong>filesize:</strong>
<span data-name="filesize"></span>
</p>
</div>
<div class="acf-actions -hover">
<a class="acf-icon -cancel dark" data-name="remove" href="#" title="Delete"></a>
</div>
</div>
<div class="hide-if-value">
<label class="acf-basic-uploader">
<input type="file" name="acf[field_60bc51d2899c5]" id="acf-field_60bc51d2899c5">
</label>
</div>
</div>
</div>
Thank you.
If you want to translate just a handful of words and not the entire plugin, then you could use the following method!
So, every well-developed plugin/theme has a text domain associated with it, so that you could hook into it and manipulate any text generated by that plugin/theme. For example text domain for woocommerce plugin is woocommerce! For ACF plugin, it's acf!
Usually you could find the text domain in the main file of the plugin. For ACF plugin you could find it in the acf.php located in the root directory of the plugin. See the screenshot below!
After you found the text domain then you could hook into it using gettext, ngettext etc. filter hooks! See the code below:
add_filter('gettext', 'your_theme_translate_acf_fields', 20, 3);
function your_theme_translate_acf_fields($translated, $text, $domain)
{
if ('acf' == $domain) :
switch ($translated) {
case 'No file chosen': // THIS IS THE TEXT GENERATED BY THE ACF PLUGIN
$translated = 'ファイルが選択されていません';
break;
case 'Choose File': // THIS IS THE TEXT GENERATED BY THE ACF PLUGIN
$translated = 'ファイルを選ぶ';
break;
}
endif;
return $translated;
}
Notice: Capitalization matters!
Code goes to your functions.php of your active theme. Tested and works!
Wordpress translation filter hooks:
gettext
ngettext
If you want to translate any plugin first, check the .pot file. The file is inside wp-content>plugins>plugins-name>languages. You can edit the file with POedit. You can translate to any language.
I am making a WooCommerce website where I want to have a pop-up when someone clicks on apply now button. There I want to have two fields 1) All the class(custom field) that product has. 2) Kids that the current logged in user has.
And there would be Add to Cart button which would add the item inside the cart.
I have successfully been able to get those on my product page. I am using toolset https://toolset.com to create my product listing page and single product page.
This is my code for a single product list (Template View)
<div class="school">
<div class="top">
<div class="image">
[types field="logo"][/types]
</div>
<div class="city">
<img src="link_to_img">
[types field="city"][/types]
</div>
</div>
<div class="middle">
<p>[wpv-post-title]</p>
</div>
<div class="bottom">
[wpv-post-read-more]
<button class="applynow" href="#">Apply Now</button>
</div>
</div>
Also this is the code to render those fields 1 & 2 in the popup. I am using this in my single product page.
function iconic_output_engraving_field() {
global $product;
$classes = get_post_meta($product->get_id(),'wpcf-classes-opened-for-admission',array('show_name' => 'true'));
print_r("<label>Select Class</label>");
print_r("<select name='class'>");
print_r("<option disabled selected value> -- Select a Class -- </option>");
foreach ($classes as $class) {
print_r( "<option value='".$class[0]."'>".$class[0]."</option>");
}
print_r("</select>");
$args = array(
'id' => 1538,
);
echo render_view( $args );
}
add_action( 'woocommerce_before_add_to_cart_button', 'iconic_output_engraving_field', 10 );
How can I pass the id through the button, so that I can create a template which loads up with correct data and Add to Cart button.
https://wordpress.org/plugins/easy-login-woocommerce/
This plugin does what you're looking for, BUT it uses wp_user_login or some other function that you would need to change.
Basically, download, check the code of the plugin, your answer should be there.
Plugin is to create a popup when a button is clicked, plugin uses it to login/register, but you could edit to do whatever.
On my WooCommerce checkout page, I am selling only one product. The checkout page is showing this product and there is ckeckbox next to it, to show the shipping details, when clicked. This is on the default form-checkout.php WooCommerce template.
I would like to have this ckeckbox always selected, to show billing details by default.
I have tried to set:
$checkout = 1;
With no luck so far. The radio button is displayed by the following hook:
<?php do_action( 'woocommerce_checkout_before_customer_details'); ?>
Any help letting me know how I can achieve this will be very helpful.
Thanks.
If you look to the code of checkout/form-shipping.php WooCommerce template, inside the <h3> tag, where the checkbox code is located, there is woocommerce_ship_to_different_address_checked hook that you can use to achieve that. Here is an extract of this code template, that shows it:
?>
<div class="woocommerce-shipping-fields">
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
<h3 id="ship-to-different-address">
<label for="ship-to-different-address-checkbox" class="checkbox"><?php _e( 'Ship to a different address?', 'woocommerce' ); ?></label>
<input id="ship-to-different-address-checkbox" class="input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" />
</h3>
<div class="shipping_address">
So you can use this hook this way, to get this checkbox always selected and displays billing details:
add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true');
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
The code is tested and fully functional.
I added this PHP function to display the excerpt of my products on the archive pages, however it affects the rest of my styling.
I'm trying to stop the CSS from my excerpts to affect the rest of the page. Basically I would like only the text without its own styling or bullets, or images, etc.
This is the code added :
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); ?>
add some html to your excerpt.. to target only that certain html...
example, adding a div with a class my-excerpt:
<div class="my-excerpt">
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); ?>
</div>
your css would then be:
.my-excerpt img {
border: 0;
}