Hi I just got into wordpress theme development and I have seen many developers when setting the attribute for in for a function in an array use this sintax:
'name' => __( 'Portfolio'),
'singular_name' => __('Portfolio'),
I have tryed it and I could not find it any difference then writing it like this:
'name' => 'Portfolio',
'singular_name' => 'Portfolio',
Aldo I am a total beginner in both php and wordpress so maybe that's why.
So is there a difference beetween the two ways of writing?If so witch is better?
This is the Wordpress method of returning the proper language value through the localization module. Check this link for more details:
http://codex.wordpress.org/Translating_WordPress
Related
I am building an Admin page for my themes. In the admin page, it will be possible for admins to go to the options page and select how many custom post types they want to open. I've already got the first part running (the page where they put in how many custom post types they want, and what the names of those custom post types should be). I am having trouble with the second part: using a foreach loop to get information that has been collected in the first step and putting it through a function to register that post type.
When using a regular function, it will get a fatal error about not being able to redeclare the same function.
When putting the function outside of the foreach-loop, I will not be able to get the information per loop-item.
Putting the function inside of a variable has me wondering how I can still use a functionname to have an add_action hook it into WordPress.
I cannot find a solution that works, or that at least I understand. I am about usually able to handle PHP quite alright, especially with regards to working in WordPress. And although the problem feels simple, the solution might be way over my head.
Start of the foreach-loop:
foreach($custom_post_type_select as $custom_post_type) {
$custom_post_type_number = $custom_post_type_integer+1;
$custom_post_type_name = "custom_post_type_name_$custom_post_type_number";
$register_custom_post_type_name = $custom_post_type_selection[$custom_post_type_name];
$custom_post_type_marker = "custom_post_type_activate_$custom_post_type_number";
$register_custom_post_type_activate = $custom_post_type_selection[$custom_post_type_marker];
Registering the custom post type:
function register_custom_post_type() {
$args = array(
'public' => true,
'labels' => array(
'name' => $register_custom_post_type_name,
'singular_name' => $register_custom_post_type_name,
'public' => true,
'has_archive' => true,
'supports' => array('title'),
'show_ui' => true);
register_post_type($register_custom_post_type_name,$args);};
if(stripos($register_custom_post_type_activate,'yes') !== false) {
add_action('init','register_custom_post_type');}
And the end of the foreach-loop:
if(++$custom_post_type_integer == $custom_post_type_variable)
break;}}
How would it be possible to both use the foreach-loop to get the right information and a function that is being called by an add_action?
I'm trying to add a Product Bundle to an Order (or a Cart, add_bundle_to_cart uses the same args). The Bundle has several child products, all of which have variations. The args I need to be providing according to the documentation are:
$args = array(
81 => array(
'product_id' => 1543,
'quantity' => 3,
),
84 => array(
'product_id' => 1386,
'quantity' => 1,
'variation_id' => 3535,
'attributes' => array(
'attribute_pa_attribute-1' => 'value-1b',
'attribute_pa_attribute-2' => 'value-2b',
),
)
);
Where the second bundled product (84) is a variable product. My issue: I cannot verify whether the values I am providing for the 'attributes' array are correct.
My attribute is named 'Servings' and there are two options - '2 People' and '4 People'. I am not sure how to format the attribute name to replace 'attribute_pa_attribute-1'. I have tried 'servings', 'attribute_pa_servings', etc. If I return the variation information for the product it gives me: 'attribute_servings' as the name and '2 People' as the value. But that doesn't seem to work either.
I am not getting any errors returned in debug.log, and I cannot find any examples of someone using this in the land of Google.
If anyone has any experience with this, I would greatly appreciate a tip as to what I am doing wrong.
Many thanks.
I came to realise there are two different types of 'attributes' in Woo: global attributes (across all products), and local attributes (specific to one product). The quoted instructions from the documentation are referring to how to reference global attributes - I am using local ones. So that is why the terms weren't working.
General overview here.
Information on the syntax between the two here.
Okay, so I have created a new custom post type, named sectors, and a sub category for this, named categories.
add_action( 'init', 'create_sector_cat' );
function create_sector_cat() {
register_taxonomy(
'SectorCategories',
'sectors',
array(
'label' => __( 'Sector Categories' ),
'rewrite' => array( 'slug' => 'sectorcategories' ),
'hierarchical' => true,
)
);
}
Now, when I press sector categories, it shows all categories which are created, using a file named sectorcategories.php
I then will have different 'products' inside this category, and I understand the filename should be taxonomy-sectorcategories.php, but this file isnt working?
The first parameter is the taxonomy name. and according to the Wordpress codex it should only contain lowercase letters and the underscore character. Read more
I see you have a capital letter in your taxonomy name and that might be the problem. I could be wrong but I have run into trouble with this as well, i think it is very case sensitive.
ps: I know this answer comes late but it if it works it might still help someone else.
I'm new to the Yii framework and I'm trying to access a property of the of a widget let's say CMenu where I want to change the values of some public properties like activeCssClass, firstItemCssClass, lastItemCssClass, htmlOptions etc. so how do you change the property of a widget in Yii.
Details:
I'm using Yii version 1.1.12 (Aug 19, 2012) and I'm trying to generate a multilevel menu but I need to change the values of some public class parameters and I don't know how?
Well, normally you apply needed values when you call the widget. You set them at the appropriate array inside widget call after widget class name.
$this->widget('zii.widgets.CMenu',
array(
'items' => $items,
'id' => 'main_menu',
'htmlOptions' => array('class' => 'nav'),
'activeCssClass' => 'active',
'firstItemCssClass' => 'first_item'
)
);
BUT! If you want to apply the values after you created some widget, but have not rendered it yet (really rare case) you can do this thing:
$widget = $this->beginWidget('application.components.MyOwnWidget');
$widget->public_property = 'aaa';
$widget->renderSomething();
$this->endWidget();
Adding on the previous answer, in case you missed it, don't forget to check the short and simple official documentation on this.
I am using
SugarCRM Pro 6.4.4
php 5.3.0
apache 2.2.11
My problem is that clicking the Reports module would display a text-formatted response (JSON format). When clicking the Create Report would also respond the same. I was expecting the Report Wizard wherein I could choose whether my report would be in Rows and Columns, Summation or more.
Below is a part of the response sent by Sugar.
ACLAllowedModules = ["Leads","Cases","Bugs","Prospects","Project","ProjectTask","Campaigns","CampaignLog","Releases","Contacts","Accounts","Opportunities","Notes","Calls","Emails","Meetings","Tasks","Users","Currencies","Trackers","TrackerSessions","TrackerPerfs","TrackerQueries","Documents","DocumentRevisions","EmailAddresses","Teams","Quotes","Products","ProductTypes","ProductCategories","Forecasts","Contracts","KBDocuments"]; var module_defs = new Object(); default_summary_columns = ['count'];
I tested the reports module in sugarcrm pro 6.1.6 but the result is okay.
Update:
I have fixed the problem. Turns out, sugar is calling a classname that is invalid. Corrected the classname and it is now working. By the way, the classname sugar is calling is a customized/overriden classname.
I had this error occur as a result of a bad vardefs.php custom field definition in a custom module. In my specific instance, I was trying to make a custom field pull from a custom list of values with the following code.
Bad vardefs code:
'customField' => array(
...
'type' => 'enum',
'function' => array(
'name' => 'getCustomListOfValues',
'params' => array('foobar')
)
...
),
My issue was fixed by breaking out the function params:
'customField' => array(
...
'type' => 'enum',
'function' => 'getCustomListOfValues',
'function_params' => array('foobar')
...
),