Sunday, June 30, 2013

Creating an options panel - day 3

Still no responses on the other thread so I'm creating a new one: http://wordpress.stackexchange.com/questions/104632/options-php-loop-wont-show

Already got some help and are narrowing everything down.  Well I feel very stupid.  I forgot to actually  call the them_options function forth.  To do so, all I had to do was add_action('init', 'theme_options'); which I knew already, I just kept missing it.

Another problem occurred with the save button not working so I've posted a new question on it here: http://wordpress.stackexchange.com/questions/104734/theme-options-save-button-is-not-working

I don't mean to rely on them for help but I've been struggling with it for a few hours now and are stuck.

In the meantime, I'm taking written notes on the source code from this tutorial: http://wp.tutsplus.com/tutorials/creative-coding/how-to-integrate-the-wordpress-media-uploader-in-theme-and-plugin-options/

These are some of the functions I've learned about:

That's it for today.

Thursday, June 27, 2013

Working with the options panel - day 2

/vent

Today I'm just fucking stressed and annoyed.  I can't even get the damn reset/save buttons to work fucking properly.  Here's the current options.php: http://pastebin.com/2P31BgcW

Every time I hit the reset or save button I get "You do not have sufficient permissions to access this page".  Now why wouldn't I?  I'm the admin of the blog but I don't have permissions to save/reset the options apparently.  This means something is up with my fuckinround_add_admin function.

The thing in this function that I think is causing the error should be this guy: http://codex.wordpress.org/Function_Reference/check_admin_referer

But why?  I can't find anything wrong with that.. So I'm going to continue looking aaaaaannnnnndddddd found it!  It's the fucking header method causing the problem.  I can't do options/options.php most likely because I can't view directories like that.  If I just change it too options.php it appears to work fine.

Although it appears to be working, it might not work at all when I actually write the loops and try to save the properties.  So now I'm onto writing them...

Well I've tried writing loop 1: http://pastebin.com/cK7APede
But nothing wants to show up on the page.  Why?  idk yet.  If I do echo <h1>test</h1>; just outside of the foreach loop it works perfectly.  However when I put this inside of the foreach loop it's a nogo. This means that (a) The options aren't declared properly (b) The options aren't declared before they are used (c) Something completely different than what I'm thinking is going wrong.

Asked a question here regarding it: http://thematictheme.com/forums/topic/options-panel-loop-isnt-showing/
Now I'm just awaiting a reply...

Well, it's 12:20AM and there's still no replies and I'm tired as fuck so I guess this is where I end today.

Tuesday, June 25, 2013

Creating an advanced options panel - day 1

I just graduated recently and I've been too busy spending time with the fam and homies to actually post anything here.  What I have done over this time was almost completely dissemble (till I took the motherboard out), get the dust out of, and assemble my Acer Aspire One 532h-2588.  I used this guide to do so: http://erkinson.altervista.org/acer-aspire-one-532h-aggiornare-ramhdwifi-smontare-lcd/
And no, I don't speak Italian, I translated the article (obviously).  Everything was very easy to put back together except for the damn keyboard.  The main reason was that the ribbon cable used to connect it was very folded and almost impossible to secure (but I got it).

Today I've started creating an advanced options panel today.  These are some of the guides I'm using so far:

My idea is to have too loops in the creation of the panel.  The first will be used to create a side navigation that is used for navigating through each container that has options in it (so it will only use the items in the array with the sidebar type.  The second loop will be used to create the needed containers to go along with the side menu and fill them with options.

Once this is done, I'll need to write some simple js to fade in and out of containers depending on the one clicked in the side menu.  As for the save changes input functions, I think I can just copy/paste it from either the first article above or just rewrite it from one of the books I own.  This is all I'm posting about now but I'm going to continue working throughout tonight.

My goal is to make it look almost exactly like this:

Wednesday, June 19, 2013

Integrating WP Plugins/Widgets into your theme

Tonight I'm trying to figure out how to integrate widgets I write into my theme.  This way, when the user install the theme, the widgets will be there for them to use.

To do so you just need to:

  • import all the widget files into your theme directory
  • Make sure any hardcoded paths or plugin_urls are changed to get_template_directory_uri() and the correct path.
  • Add a require_once to your functions.php with the path of your widget's php file inside.
Notes:
  • When integrating make sure to delete it from the plugins directory or else you'll get an error that says you can't redefine that class.
Now that I have shortcodes and integrating plugins/widgets into the theme I can now start working on making an advanced admin panel.  This admin panel would include the following options:
  • Change logo/if you want a logo at all.
  • Change background image/color.
  • Change link color.
  • Change header text color.
  • Custom css.
  • Insert google analytic code.
  • Enable/disable image slider.
  • Enable/disable jQuery.
All of these need to be placed in a tab for their category of option in the options panel too.  That's all for tomorrow night though cause tonight's energy drink is wearing off already.

Monday, June 17, 2013

Conversion

It's been a while since I posted because of four reasons:
  • laziness
  • social life
  • new conversion
  • finals :(
Anyways, I did a new psd to html conversion called **** Host.  It's a three page web hosting layout that I used as much css3 as possible on:

EDIT: The design I coded was apparently ripped from another designer.  I feel bad about doing this so I've removed all the pictures of the coded design etc.  It's amazing how many fag rippers are on the internet these days.

Tuesday, June 11, 2013

vbulletin skins?

I spent majority of my time on the computer today derping around.  Other than that I decided to take a break from wp and check out how vbulletin skins work.  These two sites help with understanding how  a skin works:
I can only read and not actually try this stuff out today because I don't have a nulled vbulletin to run on my localhost and TPB is down for whatever reason.  I don't trust the torrents from other sites either like torrentz.eu and kickass torrents.  The thing that makes me nervous about downloading so many things is opening a virus and having all my account data stolen.  Sometimes when I'm really paranoid, I convince myself that I already have a virus and go crazy with scans/checking folders/processes where it could possibly be.  It'd probably be a good idea to ask the experienced members on HF if my comp is infected because I feel my paranoia coming in again. 

Monday, June 10, 2013

My progress with shortcodes

Tonight I messed around with shortcodes more so they look like this:


Some things I should probably do is make it so when the inline toggles are next to each other, the ones on the end will get the .last class and float:left;clear:right;.  I want the same to happen for the alerts.  I should also make it so when the width is fixed that they should clear:both;.  A style attribute for all the elements wouldn't hurt either.  When all this is complete it'd be a good idea to look into packaging this. Nothing else happened today besides a shit ton of calculus so pce.

Sunday, June 9, 2013

Fucked myself over

I was on a nice little vacation after prom and I've come home to the realization of how badly I fucked myself over.  Because my dumb ass accidentally (I'm not explaining any further) got involved in some type of fraudulent activity involving PayPal, I've found myself banned from using the processor FOR LIFE.  Now, lifetime bans aren't fun if you get them for any site, but one from PP tends to sting a bit more than usual.  Why?

  • PP is the #1 most used payment processor in the world and most accepted by online businesses/potential customers for my web designing services.
  • I can never sell things on ebay with my own account.
  • I can't pay for things that only accept PP (which are a lot).
Now what about using Payza instead?  They won't allow new accounts to be created in the US currently.  Which means the only payment methods I can accept are:
The first option is always a backup and Western Union seems like the way to go now.  I've used moneybookers before and I just don't know them well enough to trust them with my bank info/money.

What should you deduct from reading this?
  • Always write passwords/security answers down.
  • Never do fraudulent activity with any payment processor as a kid because it can fuck you over when you're an adult.
  • Even if you're banned from someplace there are still plenty of other options (that probably aren't as good) out there.

Wednesday, June 5, 2013

Revisiting the Wordpress Shortcode API

I'm creating a new wordpress in my localhost just for practice.  Just for remembering purposes, the url is localhost/fucking round.  I know, it's very mature of me to use a curse word in the directory name.

With everything set up I'm choosing to practice making shortcodes because I'm not familiar with them at all.  First though, I'm going to take some notes on this: http://codex.wordpress.org/Shortcode_API

Basically a shortcode is a placeholder that you put in posts that gets replaced with the code when displayed.  It's kinda like when you use :ninja: in the chatbox at wj to get a ninja smiley.  Shortcodes can also have attributes (color, size, id, etc.).

Then to write a shortcode, in your functions.php, you just have to write a function that returns the html/text you need and use add_shortcode() for that function: http://codex.wordpress.org/Function_Reference/add_shortcode

There are three parameters included in the shortcode callback:
  • $atts, is an optional array of attributes.
  • $content, is the content of the shortcode (obviously)
  • $tag, is a tag for the shortcode, used for shared callback functions.
The shortcode api will replace any shortcodes [thatlooklikethis] and parse all the attributes and content.  Content will only be placed in the post body if it's returned and not echoed.  A shortcode handler would get put into the body instead of the shortcode already programmed.

So say you have something like: [scode dont="touch" me="there"]

The $atts would be: array( 'dont' => 'touch', 'me' => 'there' )
$atts[0] holds a string that was used to match the shortcode regex if (and only if) it's different from the callback name.

shortcode_atts (resembles wp_parse_args) is used to set a default for missing values and get rid of any attributes that the shortcode doesn't understand: http://codex.wordpress.org/Function_Reference/shortcode_atts
This would get placed inside of an add_shortcode handler function like this:
function my_shortcode_handler( $atts, $content = null ) {
   extract( shortcode_atts( array(
      'attr_1' => 'attribute 1 default',
      'attr_2' => 'attribute 2 default',
      // ...etc
      ), $atts ) );
}

Here, extract (http://www.php.net/extract) pulls the needed values from the array and will handle any collisions after shortcode_atts() strips out all the non-included keys.

This tip is important regarding naming attributes:
$atts values are lower-cased during shortcode_atts( array( 'attr_1' => 'attr_1 default', // ...etc ), $atts ) processing, so you might want to just use lower-case.
 Shortcodes get parsed after wpautop and wptexturize formatting is applied, meaning it won't have the proper html (p and br) tags added or curly quotes applied.  To format the shortcode, just call wpautop() and wptexturize when you return the output from your handler.  If there's a lot of html in the shortcode you can use ob_start() to capture the output and convert it to a string:
ob_start();
?> <HTML> <here> ... <?PHP
$output_string = ob_get_contents();
ob_end_clean();

Besides using self-closing shortcode, you can enclose shortcodes by using this format in posts: [shortcode]content[shortcode].  Doing so will not send the second (content) parameter to the handler so you'd have to set the handler's default value:
function my_shortcode_handler( $atts, $content = null )

Don't know what kind of closing a shortcode has?  You can use is_null($content) to figure that out.  Other html can be embed in $content since it's not encoded or escaped but you can add another shortcode unless you output it using do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode

You can mix forms of enclosing or non-enclosing shortcodes:
[sc title="steez" /] this aint [sc] working [/sc]
This would output: this aint [sc] working

Enclosing shortcodes work the same way as self-enclosing.  An example:
function caption_shortcode( $atts, $content = null ) {
   extract( shortcode_atts( array(
      'class' => 'caption',
      ), $atts ) );

   return '<span class="' . esc_attr($class) . '">' . $content . '</span>';
}


Input: [caption class="headline"]My Caption[/caption]
Output: <span class="headline">My Caption</span>

You cannot use square brackets in attributes.  So [sc attribute="[this will not work]"].

There's a few other things to note about shortcodes but I think I've summarized the important stuff.

Tuesday, June 4, 2013

Limiting the amount of tags displayed beneath posts in Wordpress

For displaying tags, _s theme uses this function: http://codex.wordpress.org/Function_Reference/get_the_tag_list

This saves me from a few extra lines of php but my goal is to limit the amount of tags displayed under a post.  Now I could always accomplish this in jQuery by hiding the extra ones, but I wouldn't be able to hide the seperators also and this isn't as efficient as through the actual loop.

So this is what I need to use instead: http://codex.wordpress.org/Function_Reference/get_the_tags

And this is what I came up with to limit the tags to only four posts per post:
<?php
$tags_list = get_the_tags();
$tags = 0;
if ( $tags_list ) :
?>
<span class="tags-links">
<?php
foreach ($tags_list as $tag){
if ($tags < 4){
echo '<a href="'. home_url() . '?tag=' . $tag->name . '">' . $tag->name . '</a> ';
}
$tags++;
}
?>
</span>
<?php endif; // End if $tags_list ?>


$tags_list holds all the tags and $tags is used as our counter.  The rest of the code is pretty self explanatory.

Monday, June 3, 2013

animeSeries - Finished Theme

I wasn't able to post the finished theme due to being busy irl but here's some pictures of everything.

~Home Page~


~Options & Widgets~


I know the options panel sucks and is extremely simple but that's about as far as I'm going to go for a wordpress theme I'm making for someone else for free.  Overall, I'm pleased with the way this came out but I know that when I start getting paid to do this it needs to be 1000x better.  I'll post a link to the site (should be able to figure it out already) if the person I made this for ever hosts it.  As for now, pce niggs.

EDIT:
The url is: http://animeviews.org/
I didn't know it was a warez site which I don't really like associating my name with but it's whatever.  The site isn't that big anyways and it's servers suck so I don't think I'll get in any trouble.  After all, I only made a theme.  I never illegally uploaded any files.

EDIT AGAIN:
The fucker isn't even using the theme.  I've followed his design almost exactly how he wanted and so he switched back to his old theme?  Some people have a strange way of showing their appreciation.