Change CSS classes in WooCommerce Theme - php

in my home Page there is a list item
<ul class="nm-products products xsmall-block-grid-1 small-block-grid-2 medium-block-grid-3 large-block-grid-6 grid-default layout-static-buttons attributes-position-thumbnail has-action-links">
I Want to change xsmall-block-grid-1 TO xsmall-block-grid-2 for small screens.
I looked into the functions.php and found this:
// Categories layout classes
$categories_class = ' toggle-' . $nm_theme_options['blog_categories_toggle'];
if ( $nm_theme_options['blog_categories_layout'] === 'columns' ) {
$column_small = ( intval( $nm_theme_options['blog_categories_columns'] ) > 4 ) ? '3' : '2';
$categories_ul_class = 'columns small-block-grid-' . $column_small . ' medium-block-grid-' . $nm_theme_options['blog_categories_columns'];
} else {
$categories_ul_class = $nm_theme_options['blog_categories_layout'];
}
But i don't see how to I can edit TO Xsmall bloc grid.
I tried to chande the inside the .xsmall-block-grid-1{} class in the grid.css file but it didn't worK.
I don't know if it's allowed to give you the link to my website so to you can inspect.

Related

Remove Quantity number before stock status in Woocommerce?

i use plugin called WC Product Stock Status into my Woocommerce site, and want to remove number before stock status. I tryed to see if quantity number is set in different CSS class, but seems that is all in one class, so hidding via CSS looks not possible.
.woocommerce div.product p.stock
{font-size: .92em;}
.woocommerce div.product .s_in_stock_color {
color:#77a464;
}
Unfortinally this plugin is outdated and looks no longer supported be author, so asking question on plugin page, is useless. So i want just to remove number of quantity that is in stock, and keep the label, like on image bellow:
I checked into code and found that that table is generated fetching this data in class-variable-status.php file:
public function print_stock_status(){
global $product;
if($product->is_type( 'variable' ) ) {
$childrens = $product->get_children();
$values = array();
foreach($childrens as $child){
$prod = wc_get_product($child);
$search_replace = array();
$search_replace['%formatted_name%'] = $prod->get_formatted_name();
$search_replace['%name%'] = wc_get_formatted_variation($prod);
$search_replace['%sku%'] = $prod->get_sku();
$search_replace['%id%'] = $prod->get_id();
$format = wc_pstocks_option('variable_title');
$format = str_replace(array_keys($search_replace),array_values($search_replace),$format);
$status = $prod->get_availability();;
$status['title'] = $format;
$status['ID'] = $child;
$status['formatted_name'] = $prod->get_formatted_name();
$status['name'] = wc_get_formatted_variation($prod);
$status['sku'] = $prod->get_sku();
$status['id'] = $prod->get_id();
$values[$child] = $status;
}
$this->generate_table($values);
}
}
public function generate_table($values){
wc_pstocks_get_template('stock-variation-
table.php',array("args"=>$values));
}
and this is code from stock-variation-
table.php
<?php
foreach($args as $arr){
$text = empty($arr['availability']) ? '' : '<p class="stock '.esc_attr($arr['class']).'">'.$arr['availability'].'</p>';
echo '<tr>';
echo '<td>'.$arr['title'].'</td>';
echo '<td>'.$text.'</td>';
echo '</tr>';
}
?>
I think that something neeed to be updated into this line:
$text = empty($arr['availability']) ? '' : '<p class="stock '.esc_attr($arr['class']).'">'.$arr['availability'].'</p>';
Any help how to remove that?
I was able to fix myself.. This is what i do:
From Woocommerce settings goes to Products>Inventory and just set this:
Now showing statuses, but without quantity.

Adding activity in a section in Moodle - not saving the section

So I've been looking for 2 days into this problem, I can't find either where the code exists, or how to edit/fix it.
What is happening is that when you click "Add Activity or Resource" while editing a course, it adds the activity or resource, but always into section 0. It doesn't save which section I've clicked from, and when the redirect to course/modedit.php happens, the URL shows section=0, no matter if from section 1 or 10. Further to this, moving the activity into other sections also does not save - it simply re-orders the activity to the last one in section 0.
I am unsure as to which code is causing this issue. I need some help or guidance on where to look to begin debugging and fixing this.
I also can't be sure when this issue first appeared, as I have modified a few files in between while developing this site. The only one that may be relevant (from what I can surmise), and may help give some clue for anyone better informed than I is the following:
protected function section_header($section, $course, $onsectionpage, $sectionreturn=null) {
global $PAGE;
$o = '';
$currenttext = '';
$sectionstyle = '';
if ($section->section != 0) {
// Only in the non-general sections.
if (!$section->visible) {
$sectionstyle = ' hidden';
} else if (course_get_format($course)->is_section_current($section)) {
$sectionstyle = ' current';
}
}
$o.= html_writer::start_tag('li', array('class' => 'section main'.$sectionstyle));
// Create a span that contains the section title to be used to create the keyboard section move menu.
$o .= html_writer::tag('span', $this->section_title($section, $course), array('class' => 'hidden sectionname'));
$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
$o.= html_writer::tag('div', $leftcontent, array('class' => 'left side'));
$rightcontent = $this->section_right_content($section, $course, $onsectionpage);
$o.= html_writer::tag('div', $rightcontent, array('class' => 'right side'));
$sectionname = html_writer::tag('span', $this->section_title($section, $course));
$o.= html_writer::start_tag('a', array('href' => '#section-'.$section->section, 'class' => 'title'));
$o.= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
$o.= html_writer::end_tag('a');
$o.= html_writer::start_tag('div', array('id' => 'section-'.$section->section, 'class' => 'content'));
// When not on a section page, we display the section titles except the general section if null
$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
// When on a section page, we only display the general section title, if title is not the default one
$hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name)));
$classes = ' accesshide';
if ($hasnamenotsecpg || $hasnamesecpg) {
$classes = '';
}
$o.= html_writer::start_tag('div', array('class' => 'summary'));
$o.= $this->format_summary_text($section);
$context = context_course::instance($course->id);
$o .= $this->section_availability_message($section, has_capability('moodle/course:viewhiddensections', $context));
return $o;
}
That is my rework of the layout - allowing for a simple Jquery accordian to show/hide the sections. The Jquery is:
$(document).ready(function() {
function close_accordion_section() {
$(".topics .title").removeClass("active");
$(".topics .content").slideUp(300).removeClass("open");
$("#section-0").stop();
}
$(".title").click(function(e) {
// Grab current anchor value
var currentAttrValue = $(this).attr("href");
if($(e.target).is(".active")) {
close_accordion_section();
}else {
close_accordion_section();
// Add active class to section title
$(this).addClass("active");
// Open up the hidden content panel
$(".topics " + currentAttrValue).slideDown(300).addClass("open");
}
e.preventDefault();
});
});
I have edited nothing else in relation to the course page, but that doesn't mean the issue might not be elsewhere.
Sorry for the wall of text, but please could someone help me find why the Activity isn't adding to the right section, nor allowing me to move into the right section afterwards? I'd really appreciate it.

Wordpress do_shortcode strange behavior

I am developing a WP plugin which processes shortcodes and displays amazon item data in place of them. The plugin is working as desired, except for a little strange behavior. You can see my test run at http://passivetest.themebandit.com/test-post-for-zon-plugin/ .
If you scroll down on that page, you can see that 4 "1" s are appended to the content. The shortcode is processed 4 times in this page, and each time WP is adding an undesired 1 to the output. I don't understand why this is happening. There is no "1" anywhere in my html files, and its nowhere in the post content. All my functions just return the content that is to be replaced in place of the shortcode. Can someone please give an explanation for it and let me know how to remove these? Thanks in advance..
My code is as follows:
add_shortcode('zon_product', 'zon_process_shortcode');
// Zon Shortcode processor
function zon_process_shortcode($attributes, $content = null) {
global $zon_html_path;
// default options for shortcode
$options = array('asin' => '', 'style' => 'compact', 'loc' => 'com');
extract(shortcode_atts($options, $attributes));
$asin = $attributes['asin'];
// first find asin in local zon_data table
$zdb = ZonDbHandler::instance();
$product = $zdb->findASIN($asin);
if ($product) {
// if product exists in db, render template
return zon_display_product($product, $attributes);
} else {
// product does not exist in database, get data through amazon api worflow
$product = ZonLibrary::getAmazonProduct($asin, $attributes['loc']);
if ($product) {
// product data has been successfully retrieved and saved, render template
return zon_display_product($product, $attributes);
} else {
// error in fetching product data, check amazon access key id and api secret
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . 'api_error.php');
return $content;
}
}
}
// Renders selected template with product data
function zon_display_product(ZonProduct $product, $attributes) {
global $zon_html_path;
global $zon_path;
// process other shortcode options
$view_vars = array();
$view_vars['style'] = (isset($attributes['style'])) ? $attributes['style'] : "default";
$view_vars['show_price'] = (isset($attributes['show_price']) && $attributes['show_price'] == 0) ? false : true;
$view_vars['price_updates'] = (isset($attributes['price_updates']) && $attributes['price_updates'] == 0) ? false : true;
$view_vars['hide_unavailable'] = (isset($attributes['hide_unavailable']) && $attributes['hide_unavailable'] == 1) ? true : false;
$view_vars['show_desc'] = (isset($attributes['show_desc']) && $attributes['show_desc'] == 0) ? false : true;
// check if template file exists
if (!is_file($zon_html_path . 'html' . DIRECTORY_SEPARATOR . $view_vars['style'] . '.php')) {
$content = 'ERROR! Zon Template not found. Please check you are using a correct value for the "style" parameter.';
return $content;
} else {
// get product array
$product = $product->getArray();
// if product is unavailable and hide_unavailable is true, return unavailable template
if ($view_vars['hide_unavailable']) {
if ((strpos($product['availability'], "Usually") === false) && strpos($product['availability'], "ships") === false) {
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . 'unavailable.php');
return $content;
}
}
// render chosen template file
$content = include($zon_html_path . 'html' . DIRECTORY_SEPARATOR . $view_vars['style'] . '.php');
return $content;
}
}

Showing Category Count on Html Links

I have html links on my wordpress website sidebar and I would like to show the number of posts related to that link.
The posts are placed under custom listing category defined by the following function:
Php:
function va_cat_menu_drop_down( $location = 'menu', $taxonomy ) {
global $va_options;
$key = 'categories_' . $location;
$options = $va_options->$key;
$args['menu_cols'] = ( $location == 'menu' ? 3 : 2 );
$args['menu_depth'] = $options['depth'];
$args['menu_sub_num'] = $options['sub_num'];
$args['cat_parent_count'] = $options['count'];
$args['cat_child_count'] = $options['count'];
$args['cat_hide_empty'] = $options['hide_empty'];
$args['cat_nocatstext'] = true;
$args['cat_order'] = 'ASC';
$args['taxonomy'] = $taxonomy;
$terms_args['pad_counts'] = false;
$terms_args['app_pad_counts'] = true;
return va_categories_list($args, $terms_args);
}
How can I show that number of posts in a particular category next to my Html link as the following does not work (I guess as the listing category is probably custom taxonomy?)
<?php echo get_category(17)->count; ?>
There is a very simple method to do this. Use wp_list_categories and enter the argument 'show_count' => 1
http://codex.wordpress.org/Template_Tags/wp_list_categories

php creating css class dynamically

I have a code which is completed and I want to add another code inside my completed code.
completed code:
function module( $prefix, $comma_seperated_suffixes ) {
foreach( (array)explode( ",", $comma_seperated_suffixes ) as $suffix ) {
$module_name = $prefix.trim($suffix);
if(count(JModuleHelper::getModules($module_name))) {
module_block($module_name);
}
}
}
I moved count(JModuleHelper::getModules($module_name)) to module function, previously it was in module_block
please dont use tovolt class, I mean simple code without php class
Module count block
i am assuming That I am calling this modules module("top-col-", "1,2,3"); then I have three modules called top-col-1, top-col-2, top-col-3
then my count module will look like this:
$TopCol1 = (int)(count(JModuleHelper::getModules($module_name)) > 0);
$TopCol2 = (int)(count(JModuleHelper::getModules($module_name)) > 0);
$TopCol3 = (int)(count(JModuleHelper::getModules($module_name)) > 0);
above code is will just count for active module (the only way to check active module), If a module is active then its var will be 1 .
and now the time to count active module:
$topColCount = $TopCol1 + $TopCol2 + $TopCol3;
if ($topColCount) : $TopColClass = 'count-' . $topColCount;
endif;
I am counting modules case I want to set a CSS class like this count-1, count-2, count-3 to active modules. and I want that class to be used in module_block.
please keep in mind that, above variable is static cause I made them manually. but if I call function then var need to be change with the function value like if user call module("bottom", "1,2,3"); then its count_modules will be $bottom1, $bottom2, $bottom3 and class will be $bottomClass.
I want to generate count_module using the same code module("bottom", "1,2,3");
Thanks #steve for your help
If I am understanding this correctly, this should help.
tovolt class: (note the new function 'prep_modules' added to this class)
<?php
////////////////// BEGIN CLASS tovolt
class tovolt{
function tovolt() {
//// constructor function - used to setup default variable states, etc. - if this is omitted PHP may have a fit ( depending on version and config )
}
public static $TopColClass = 'default-value';
function code_block( $jdoc_name ) {
?>
<div id="top-col" class="<?php echo self::$TopColClass; ?> columns">
<div class="panel">
<jdoc:include type="modules" name="<?php echo $jdoc_name; ?>" style="html5" />
</div>
</div>
<?php
}
function module( $prefix, $comma_seperated_suffixes ) {
foreach( (array)explode( ",", $comma_seperated_suffixes ) as $suffix ) {
$module_name = $prefix.trim($suffix);
self::code_block( $module_name );
}
}
////////////////// BEGIN NEW FUNCTIONS
function prep_modules( $MODULE_LIST ) {
$READY_MODULES = array();
foreach( (array)$MODULE_LIST as $module_name ) {
$MATCHED_MODULES = JModuleHelper::getModules($module_name);
$matched_count = count( $MATCHED_MODULES );
$matched_list = implode( ',', range( 1, $matched_count ) );
$READY_MODULES[$module_name] = array(
'MODULES' => $MATCHED_MODULES,
'count' => $matched_count,
'list' => $matched_list,
);
}
}
////////////////// END NEW FUNCTIONS
}
////////////////// END CLASS tovolt
?>
content page code - near top: (prepare this page's modules)
////////////////// SOMEWHERE BEFORE THE OUTPUT SECTION, LOAD MODULES FOR THIS PAGE
$READY_MODULES = tovolt::prep_modules( 'top', 'side', 'etc' );
content page code - content output area: ( choose the method that best fits your design )
method 1 - output a single section:
////////////////// DOWN IN THE MODULE OUTPUT SECTION - TO OUTPUT A SINGLE SECTION USE:
$section = 'top';
if( #$READY_MODULES[$section]['count'] > 0 ) {
tovolt::$TopColClass = $section; //// if you need to change: $TopColClass
tovolt::module( $section."-col-", $READY_MODULES[$section]['list'] );
}
method 2 - output all in order of loading:
////////////////// DOWN IN THE MODULE OUTPUT SECTION - TO OUTPUT ALL SECTIONS IN LOADED SEQUENCE USE:
foreach( (array)$READY_MODULES as $section=>$THIS_VAR_IS_NOT_DIRECTLY_REFERENCED ) {
if( #$READY_MODULES[$section]['count'] > 0 ) {
tovolt::$TopColClass = $section; //// if you need to change: $TopColClass
tovolt::module( $section."-col-", $READY_MODULES[$section]['list'] );
}
}
method 3 - arbitrary output:
////////////////// DOWN IN THE MODULE OUTPUT SECTION - TO OUTPUT MULTIPLE SECTIONS IN AN ARBITRARY ORDER:
foreach( array( 'side', 'top' ) as $section ) {
if( #$READY_MODULES[$section]['count'] > 0 ) {
tovolt::$TopColClass = $section; //// if you need to change: $TopColClass
tovolt::module( $section."-col-", $READY_MODULES[$section]['list'] );
}
}

Categories