enable upload/insert option for contributor in wordpress

If we know about wordpress user role and their accessibility it is known that no contributor can’t upload/insert any image or can’t set feature image for their post …

there is a little code to enable this feature for each contributor anyway .. we have to edit function.php file in theme directory ..

just add the below code to enable this feature for contributor

if ( current_user_can('contributor') && !current_user_can('upload_files') )
	add_action('admin_init', 'allow_contributor_uploads');

function allow_contributor_uploads() {
	$contributor = get_role('contributor');
	$contributor->add_cap('upload_files');
}

XML Tutorial #8 : Multiple Namespaces

<?xml version=”1.0″ encoding=”utf-8″?>

<bookstore>
<c:book xmlns:c=”http://facibook.com/home/”&gt;
<c:title>Teach yourself C++</c:title>
<c:price>255</c:price>
<b:author xmlns:b=”http://facibook.com/home/”&gt;
<b:name>Herbert Schield</b:name>
<c:language>English</c:language>
</b:author>
</c:book>

</bookstore>
Have a close look at the above multiple namespace example … we define two namespaces one is for book element and another is for author element .. however you can use use the namespace of book element in the language element but you can’t use the namespace of author into any other elements that are not descendant of author …

and don’t panic about url the i have used … 🙂

Hope you understand …

By kfelahi Posted in XML

XML Tutorial #7 : Namespace scope ..

In this tutorial i am gonna talk about xml namespace scope … you may read about variable scope in c or c++ language .. however in xml namespace also have some scope ..

That is when you define an xml namespace for an element it will only work for that element and its contained descendants, this is know as the defined namespaces working area .. it does not work if you prefix the same namespace for another element or child that is not within the element where we defined the namespaces .. Look at the below example ..
<?xml version=”1.0″ encoding=”ISO-8859-1″?>

<bookstore>
<book>
<title>Teach yourself C++</title>
<price>255</price>
<b:author xmlns:b=”http://facebook.com/home/”&gt;
<b:name>Herbert Schield</b:name>
<b:language>English</b:language>
</b:author>
</book>

</bookstore>

By kfelahi Posted in XML

XML Tutorial #6 : xml namespace

Hey welcome back again … in this tutorial i will discuss about xml namespace .. As you know xml offer you to create your own elements or tags whatever you say .. so for this during the time you create a lot of element in lot of xml files a confliction between the elements name easily occur .. To remove this confliction xml also offer you to define namespaces ..

Lets see an example …

<bookstore>

                <title>Famous Freak</title>

                <price>555</price>

</bookstore>

 

<magician>

                <title>The mind freak</title>

                <name>Cris Angel</name>

</magician>

Now you have this two xml files and Suppose somehow you have combine this two xml files … when you do this an error will show up to you because magician and bookstore element both contain a descendant named title ..

Let see how can we fix the error ..

<b:bookstore xmlns:b =“http://www.website-name.com/page”>

                <b:title>Famous Freak</b:title>

                <b:price>555</b:price>

</b:bookstore>

 

<m:magician  xmlns:m =“http://www.website-name.com/page”>

                <m:title>The mind freak</m:title>

                <m:name>Cris Angel</m:name>

</m:magician>

In this code we use an attributes call xmlns that means xml name spaces which is in short form xmlns …

This is how we can fix such types of error using xml namespaces ..

By kfelahi Posted in XML

XML Tutorial #5 : Ancestor and Descendant

In this part of tutorial i will define some words that may come in front of you many times during xml coding … those are

— Ancestor

— Descendant

— Parent

— Child

— Sibling

Before i make a description of those lets create a xml code …


    <grand_parents>

          <parents>

                <me></me>

                <my_brother></my_brother>

          </parents>

    </grand_parents>

 

well in this code … <grand_parents>,<parents> are ancestor cause they have descendants .. that means <grand_parents> contains two other element and <parents> also contains elements .. but <me> and <my_brother> are not ancestor cause they does not contain any element

Again ,, <parents> and <me> and <my_brother> are descendant cause they have a root/parents …

One think you may notice that <parents> is also a descendant and ancestor .. cause <parents> have child and parent ..

— Siblings are <me> and <my_brother>

— parent are child are too much easy to understand .. they are in regular meaning …

By kfelahi Posted in XML

XML Tutorial #4: How to connect an external style sheet to xml

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<?xml-stylesheet type=”text/css” href=”3.css”?><!–This is how we connect to css file–>
<persion>
<male>
<name>Tanvir</name>
<age>22</age>
<religion>Islam</religion>
</male>
</persion>

 

 

/****************** 3.css **************/

@charset “utf-8″;
/* CSS Document */

persion,male
{
font-family:”Comic Sans MS”, cursive;

}
name
{
display:block;
font-size:24px;
color:#C69;
}
age,religion
{
display:block;
}

By kfelahi Posted in XML

XML Tutorial #3 : Fundamental Rules of XML

XML Tutorial : # 3

Basic Rules to write XML code :
—————————————

# Every xml code must have root element or document ..
# Each opening tags must have it closing tag ..
# Attributes values must be quoted ..
# Use entities for the replacement of those <,>,&,’,” signs cause those signs may change the meaning of the syntax ..
# XML is case sensitive.. <tag> and </Tag> execute as two different tag ..
# Unlike HTML XML does not truncate white spaces ..
# It also stores Line feed and Carriage return ..

 

Remember all those stuff that will help u out in xml coding ..

By kfelahi Posted in XML

XML Tutorial #2: Basic example of code

<?xml version=”1.0″ encoding=”utf-8″?>
<booklist>
<book>
<name>Teach Yourself C</name>
<author>Herberd Schield</author>
<edition>5th</edition>
<price>250</price>
</book>
<book>
<name>Teach Yourself C++</name>
<author>Herberd Schield</author>
<edition>5th</edition>
<price>250</price>
</book>
</booklist>
<!–
This is how to comment on XML .. same as HTML comment ..
–>
This is a example of Basic syntax how to write XML code … the tag <booklist> is called the root … and remain tags are called child of the root tag ..

How save and show and XML code :
————————————-
At first open up a notepad/wordpad then write this code changed the file name into anything but do not forget to change extension into .xml .. Now open it into your browser that will show the same code as well cause it is xml .. its only store the data …

By kfelahi Posted in XML

XML tutorial #1: Basic

XML Tutorial : #1

Before you starting read this tut i hope that you have good knowledge about HTML and basic concept about Javascript …

XML ..!! That stands for eXtensible Markup Language … Why its called extensible !! the reason is is that xml gives the programmer freedom to write his tag .. impressive isn’t it? .. yes it is .. as you are a html coder you know how to define tags, attributes, entity etc … all these things are also in XML ..

Then a question may be rise in your head that if almost all the things are same as html then why should we learn XML .. well, first i will say XML is not a complement of HTML ..
Difference between XML and HTML are …
———————————————
XML deals only with data .. like stroing data, transmission data etc .. but it does not show any data or some contents of a page ..

On the other hand, HTML deals how to show data or page content to a user .. it does not deals with data storing or transmission ..

Lets see how we can find it useful :
———————————————
# XML reduce the data redundancy by storing data ..
# As it store data so we can show those data in varius styles in different section of web pages ..
# XML supports other language as well ..

At last i m gonna say it is a simple language to learn(as far as i know), then what is the problem to learn it and keep going … 🙂

By kfelahi Posted in XML

__toString() magic method in oop

<?php

/*The __toString() method is automatically called when an object in PHP5 is converted into a string for the purpose of display or concatenation.*/

class ap
{
private $a;
private $b;
public function ho($a,$b)
{
$this->a = $a;
$this->b = $b;
}
public function __toString()
{
return “values are “.$this->a.” and “.$this->b;
}
}

$o = new ap();
$o->ho(11,21);

echo $o;

?>