Friday, September 20, 2013

College Fun - bootstrap framework basics

Okay guys so I'm at college now and busier than ever before.  Currently I'm working on a plugin for an image theme for a few friends on WJ.  I'm also learning to work with bootstrap as I'm getting a job developing for someone.  I can't describe any details about the job and I won't be able to post any of my work but I will be able to post everything learned about bootstrap: http://getbootstrap.com/2.3.2/getting-started.html  And I'm not going to post anything about the plugin yet, but I will as soon as it's done.  For now here's my notes/progress with the bootstrap framework:
  • Bootstrap needs HTML5 as well as jQuery
  • Bootstrap sets a basic css template to work off of that controls the global display, typography and link styles.  In specific it:
    • Found in scaffolding.less:
      • removes the body margin
      • makes the body bg color white
      • uses @baseFontFamily, @baseFontSize and @baseLineGeight attributes as our typographic base.
      • set link color with @linkColor and applies underline affect on hover
    • Found in reset.less:
  • without responsive css added, the bootstrap grid system uses a 12 col layout with a 940px wide container.
  • with responsive css, grid adapts to be 724px and 1170px depending on the viewing screen res.
    • with this the columns become fluid and stack under each other
  • Because there are 12 columns you need to make the spans add up to = 12.  For example:
<div class="row">
     <div class="span5">...</div>
     <div class="span5">...</div>
     <div calss="span2">...</div>
</div>
  • This creates a filled row.  In the old bootstrap (2.x) you used to have to enter .row-fluid but in the new version of bootstrap you just use .row* and it's fluid automatically because there's no more "fixed grid".
  • You use .offset* for shifting columns.
  • For embedding two spans it would look like this:
<div class="row">
   <div class="span10">
     <div class="row">
        <div class="span6">...</div>
        <div class="span4">...</div>
     </div>
   </div>
</div>

  • Use .container for different sections of the website.
Okay so this pretty much covers all the basics that I need to know about the bootstrap framework.

Saturday, August 17, 2013

Me again - custom image post type release

So I've successfully created the image variation custom post type which can be viewed live here: http://wpprojects.net63.net/?image_post=testing-the-image-post-type

The code for it can be seen here: https://gist.github.com/C-onnor/6258300

I like the way it came out.  I'm sure I'll think of some new changes and other people will as well if they look through the code.  Another thing of done today is messed with the content.php file and made it so only images will be displayed on the homepage and a no-image picture will be shown if there was no featured image set: http://pastebin.com/atzAXQZ5

What's next?  Idk, people keep promising me work and shit but so far no ones actually come through for me even when I'm doing everything for free.  I'm gunna go back to making that b4b theme now and I'll save that for next post.

Wednesday, August 7, 2013

Adding a custom meta box to a custom post type day 2

Continuing off of yesterday, now that I have the CPT (custom post type) publishing problem solved I'm concentrating on the meta box again.  I need to figure out a way to add inputs for inputting data.  How?  I'm not sure yet so I've decided to take a look at this plugin, http://wordpress.org/plugins/ml-slider/, that uses something similar with the add slide button.

I looked at the code from this for a couple of hours and got nowhere.  So I foraged through a bunch of google search results and found code that does exactly what I wanted to do: https://gist.github.com/da1nonly/2057532
I mean it doesn't have the exact columns (inputs) I need but that's for me to change.  First I need to understand the results and it's a bit late for that right now so I'm going to bed.  Goodnight people.

Adding a custom meta box to a custom post type day 1

Building off of yesterday's progress (http://persteezy.blogspot.com/2013/08/custom-post-types-in-wordpress.html) there was an argument called register_meta_box_cb that was for a callback function that could be used to add a custom meta box using the add_meta_box func: http://codex.wordpress.org/Function_Reference/add_meta_box
add_meta_box(id, title, callback, post type, context, priority, callback args);

  • id - ID of the meta box section
  • title - visible title of the meta box
  • callback - function for generating the meta box html and can only accept two args from the callback args parameter.
  • post type - the post type you want the meta box in (Can I add this to the default post?)
  • context - choose where you want the meta box (normal, advanced or side)
  • priority - choose how important (placementwise) the meta box is
  • callback args - arguments passed on to the callback func
So with just a few additions/mods to the code this is what it looks like now: http://pastebin.com/89rrkuww
Which makes the image post type look like this:

Now reading through tutorials for creating inputs (http://wp.tutsplus.com/series/reusable-custom-meta-boxes/) they seem to follow outdated techniques I saw when first trying to create my options panel.  Skimming through other tutorials (that are a bit newer), I'm seeing the same thing.  What gives?  So the add_settings_section, add_settings_field and register_setting can't be used here?  Well, I'm going to try using them anyways and I'll see how that works out for me (hopefully well).

After trying out the settings api they do in fact work but only with the save changes button which wouldn't work.  I've also coded it the wrong way: http://pastebin.com/h0TZ1b3Z

So starting over again I need to rethink how I'm going to code this.  Before that comes though I've found that the post type isn't even working.  I keep getting the error "You are not allowed to edit this post" so I went to stackexchange for help: http://wordpress.stackexchange.com/questions/109243/cant-publish-custom-post-type-you-are-not-allowed-to-edit-this-post/
And with the community's help I found a fix but I'm unsure why it's working.

I meant to post this last night but forgot so I'm posting it today lol

Monday, August 5, 2013

Custom post types in wordpress

Today I've upgraded majority of my localhost wp blogs to wp 3.6: http://codex.wordpress.org/Version_3.6#Scripts.2C_External_Libraries
I've also been given a new task from someone on skype.  The task is to create a custom post type that works as the default post type but also has a custom meta box (named image) with input fields for color, size, download link.  This is a simple sketch as to what I want it to look like this:
Okay so I've messed with custom post types before but I forget how to get started with them and can't find a post on here about it so I'm just gunna take some notes on this: http://codex.wordpress.org/Post_Types

First off, custom post types get registered using the register_post_type func: http://codex.wordpress.org/Function_Reference/register_post_type
register_post_type(Name, Args);

This function must be hooked before the admin_menu and after_setup_theme hooks.  It's recommended that the init hook is used.  At the end of today using what I've read so far this is the code I've made for the custom post type: http://pastebin.com/nxvqPFu5

Now that I've learned to add the custom post type I can focus on adding a custom meta box tomorrow.

Saturday, August 3, 2013

Cool guy has chill day

Not much went on today.  I talked to a few people on WJ.  I know I said I stopped with forums but I feel I need to go back to build up a portfolio.  So while talking to people an idea popped into my head where I create a group of people looking to do free conversion services in order to buildup their portfolio.  I've created a thread to recruit people here: http://www.wjunction.com/92-development-area/177734-looking-build-your-portfolio.html
Unfortunately there have been no takers to the idea which could be foreshadowing the future.

Anyways while waiting for people to PM me I saw this thread in the dev section: http://www.wjunction.com/92-development-area/177510-why-php-domdocument-getelementsbytagname-not-finding-all-elements.html#post1868952
I could not solve his problem but in attempting to do so I learned a couple new things.   The first thing I learned was that since majority of web pages don't have properly formatted html PHP DOM will throw an amazing amount of annoying error messages that look like this:
To avoid this I followed one of the answers to this post: http://stackoverflow.com/questions/7082401/avoid-domdocument-xml-warnings-in-php

Anyways there's 13 links on the page that Filenuke (the user on wj seeking help) is trying to scrape.  His code scraped 8 links and my code scraped 9 links (not much better).  Here's my end result: http://pastebin.com/QEje2be0

Other than this, nothing else happened today.  Maybe I'll shift back into the crypter or wordpress tomorrow.  Pce!

Back from a malware attack!

Well recently I was the victim of a Java Drive-by (JDB).  I don't think the malware came from opening anything related to the crypter.  Anyways thanks to Paradoxum's help on HF the malware is gone and my system is much more secure than before.  To see everything that happened, check this thread: http://hackforums.net/showthread.php?tid=3661673

Now that this is over I'm back to posting normally again.