- Facebook Finally Adds 'Reply' Option to Comments
- Allt du någonsin har velat veta om DPI och PPI
- HTTP Archive: jQuery
Många läsvärda saker om jquery, hur man bör ladda biblioteket och hur andra gör. - Google’s Trust Problem
“All companies cancel services and abandon apps. The difference with Google Reader is that they’ve canceled something beloved.” Exakt så. - First-Hand Advice: Practical Tips From Top WordPress Pros
Utmärkta WordPress-tips - Google Keep—Save what’s on your mind
Men då tar ni inte bort tjänsten om några år, Google? Just nu ser Google Keep ut att vara som Evernote, men med sämre features och den stödjer färre plattformar. - I’m a Google Glass skeptic and think it’ll be the next Apple Newton
Jag förstår inte hypen med Google Glass alls. - As your business changes, your business model may not
- How To Create A Silo Structure In WordPress
- Building Servers for Fun and Prof… OK, Maybe Just for Fun
- How I run a membership site
Jonas tipsar 25 Mars 2013
Årets bästa låtar 2012
För fjortonde året på raken listar jag årets bästa låtar.
Listan ligger ute på topp30.se nu.
Add custom javascript and CSS to WordPress admin
A conceptual example of how you could add css or javascript to your “edit post” page in the WordPress dashboard.
I included an example of how you can “send parameters” to the javascript file.
<?php class MyClass { function admin_init() { wp_register_style( 'my_css', get_stylesheet_directory_uri() . '/css/my_class.css' ); wp_register_script( 'my_js', get_stylesheet_directory_uri() . '/js/my_class.js', 'jquery', '1.0.6', true ); } function enqueue_css() { wp_enqueue_style( 'my_css' ); } function enqueue_js() { wp_enqueue_script( 'my_js' ); // Add current post id as a javascript variable. global $post; $current_id = empty( $post ) ? '' : $post->ID; $my_params = array( 'postid' => $current_id, ); wp_localize_script( 'my_js', 'MyParams', $my_params ); } } if ( class_exists( "MyClass" ) ) $my_class = new MyClass(); else error_log( "MyClass missing" ); add_action( 'admin_init', array(&$my_class, 'admin_init') ); add_action( 'admin_print_styles-post.php', array(&$my_class, 'enqueue_css') ); add_action( 'admin_print_scripts-post.php', array(&$my_class, 'enqueue_js') ); |
Jonas tipsar 6 oktober 2012
- Hacking Diabetes
Scott Hanselman visar vilket jävla meck det är att leva med diabetes. Tänk då hur det är att vara 3 år och leva med diabetes, eller 7, eller 15. Stöd http://www.barndiabetesfonden.se/ om du kan och låt oss hitta ett botemedel för detta as till sjukdom. - CSScomb: Sorting CSS Properties, The Better Way // Free Tool
Verkar schyst, jag drar in den i textmate/sublime text 2
Jonas tipsar 6 augusti 2012
- YouTube App Will Not be Included in iOS 6
- StatCounter: Google Chrome Passes IE for Lead in Global Browser Market
4 år gammal browser, nu är den störst. - Facebook to push new code twice a day on web, update Android every 4-6 weeks
Imponerande deploy-tempo
Ny plugin, Shortcode Usage
Jag gjorde en enkel plugin för att hitta var mina olika shortcodes används. Den heter, logiskt nog, Shortcode Usage.
TextMate snippet for PRG-pattern in WordPress
This is free TextMate snippet day here at jonasnordstrom.se. Enjoy, and please let me know if there are any errors.
Post/Redirect/Get (PRG) is a web development design pattern that prevents
some duplicate form submissions, creating a more intuitive interface for
user agents (users). PRG implements bookmarks and the refresh button in a
predictable way that does not create duplicate form submissions.
PRG is the pattern to aim for when creating functionality for the WordPress backend (wp-admin). But it’s a pain to keep track of which hooks to use, how the redirection works and stuff like that.
Here’s a TextMate snippet that hopefully will be of some help.
Note: I will add nonce and update this post, just wanted to save the code somewhere when it was in front of me, you know how it is …
<?php
function ${1:function_name}_page() {
if ( isset( $POST['action'] ) && !current_user_can( '${2:edit_page}' ) ) {
return;
} ?>
<form action="edit.php" method="post">
<input type="hidden" name="page" value="${1/\_/-/}-page" />
<input type="hidden" name="action" value="${3:action-name}" />
<input type="submit" value="${4:Button Text}" />
</form>
<?php
}
function $1() {
if ( isset(\$_POST['action']) && \$_POST['action'] == '$3') {
// Do your magic here
$0;
\$location = admin_url() . "edit.php?page=" . $_POST['page'] . "&feedback=${5:Feedback+here}";
\$status = 302;
wp_redirect( \$location, \$status );
exit;
}
}
function add_$1_page() {
add_management_page( '${6:Page Title}', '${7:Menu Title}', '${8:manage_options}',
'${9:menu-slug}', '${1:function_name}_page' );
}
add_action( 'admin_init', '$1' );
add_action( 'admin_menu', 'add_$1_page' );
wpdb->delete() i WordPress 3.4
En av nyheterna i WordPress 3.4 är att metoden delete har tillkommit till wpdb-klassen. Tidigare fanns av någon anledning bara insert och update.
Enkelt exempel på hur den kan användas:
Vad jag vet finns det ingen inbyggd funktion för att ta bort alla förekomster av ett custom field, före WordPress 3.4 var man tvungen att göra en query direkt i databasen för att få till den funktionaliteten.
function delete_post_meta_for_all( $meta_key ) {
global $wpdb;
return $wpdb->query(
$wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s ",
$meta_key ) );
}
Tyvärr måste man fortfarande göra något liknande, men syntaxen är lite mer “WordPress”:
function delete_post_meta_for_all( $meta_key ) {
global $wpdb;
$result = $wpdb->delete( "$wpdb->postmeta" ,
array( "meta_key" => $meta_key) , array( '%s' ) );
}
Syntax:
function delete( $table, $where, $where_format = null )
$table: table name
$where: A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be “raw”.
$where_format Optional: An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of ‘%d’, ‘%f’, ‘%s’ (integer, float, string). If omitted, all values in $where will be treated as strings unless otherwise specified in wpdb::$field_types.
return int|false The number of rows updated, or false on error.
Jonas kuraterade länkar 12 Juni 2012
Nya kuraterade länkar. Jag letar upp och sorterar högt och lågt, ofta med fokus på teknik, media, WordPress, musik och annat som ligger mig varmt om hjärtat.
- WordPress › WordPress 3.4 Release Candidate 3
Nedräkningen till 3.4 har börjat. Inom en vecka borde den officiella releasen komma, såvida inte något allvarligt fel hittas förstås. - ★ Three Takeaways From Today’s WWDC Keynote
“there was an unmistakeable “Fuck you, Google” undertone to the whole keynote” - Push rel=”author” through your head
- De 10 bästa svenska filmerna!
Med Emmas hjälp fyller jag på listan över filmer jag måste se. - Stop asking “But how will they make money?”
- Otto on WordPress: Theme/Plugin Dependencies
- THE BOG BLOG
Funny shit - Gettext?
- The Trello Tech Stack
- I’ve Joined Automattic
Konstantin Kovshenin, ny på Automattic. Väntat och välförtjänt.

