Friday, May 10, 2013

Wordpress API programming, some first steps

So here I took a stab at wordpress, improved the documentation of a add_action call, and prepared a bunch of docs.

First of all read this :
Then get the code here : https://github.com/WordPress/WordPress
 
Then, lets look at some functions : http://codex.wordpress.org/Function_Reference/add_action

For example : Add action

 mdupont@mdupont-Aspire-7750G:~/experiments/WordPress$ grep -h -r add_action * | sed -e"s;\s;;g" | sort -u




Here are more instances that I did not analyse yet:
  • add_action('add_meta_boxes_'.$post_type,$args->register_meta_box_cb,10,1);
  • add_action('add_option_new_admin_email','update_option_new_admin_email',10,2);
  • add_action('admin_bar_menu','wp_admin_bar_add_secondary_groups',200);
  • add_action('admin_bar_menu','wp_admin_bar_comments_menu',60);
  • add_action('admin_bar_menu','wp_admin_bar_edit_menu',80);
  • add_action('admin_bar_menu','wp_admin_bar_my_account_item',7);
  • add_action('admin_bar_menu','wp_admin_bar_my_account_menu',0);
  • add_action('admin_bar_menu','wp_admin_bar_my_sites_menu',20);
  • add_action('admin_bar_menu','wp_admin_bar_new_content_menu',70);
  • add_action('admin_bar_menu','wp_admin_bar_search_menu',4);
  • add_action('admin_bar_menu','wp_admin_bar_site_menu',30);
  • add_action('admin_bar_menu','wp_admin_bar_updates_menu',40);
  • add_action('admin_bar_menu','wp_admin_bar_wp_menu',10);
  • add_action('admin_color_scheme_picker','admin_color_scheme_picker');
  • add_action('admin_enqueue_scripts',array('WP_Internal_Pointers','enqueue_scripts'));
  • add_action('admin_enqueue_scripts','_wp_customize_loader_settings');
  • add_action('admin_footer','_admin_notice_post_locked');
  • add_action('admin_footer',array(__CLASS__,'enqueue_scripts'),1);
  • add_action('admin_footer',array(&$this,'_js_vars'));
  • add_action('admin_footer','_local_storage_notice');
  • add_action('admin_footer','wp_print_media_templates');
  • add_action('admin_head','delete_users_add_js');
  • add_action('admin_head','dolly_css');
  • add_action('admin_head','export_add_js');
  • add_action('admin_head','_ipad_meta');
  • add_action('admin_head-nav-menus.php','_wp_delete_orphaned_draft_menu_items');
  • add_action('admin_head','options_general_add_js');
  • add_action('admin_head','options_reading_add_js');
  • add_action("admin_head-$page",array(&$this,'help'));
  • add_action("admin_head-$page",array(&$this,'js'),50);
  • add_action("admin_head-$page",array(&$this,'take_action'),50);
  • add_action("admin_head-$page",$this->admin_header_callback,51);
  • add_action('admin_head','_thickbox_path_admin_subfolder');
  • add_action('admin_head','wp_admin_bar_header');
  • add_action('admin_init','default_password_nag_handler');
  • add_action('admin_init','_maybe_update_core');
  • add_action('admin_init','_maybe_update_plugins');
  • add_action('admin_init','_maybe_update_themes');
  • add_action('admin_init','register_admin_color_schemes',1);
  • add_action('admin_init','send_frame_options_header',10,0);
  • add_action('admin_init','twentyeleven_theme_options_init');
  • add_action('admin_init','_wp_admin_bar_init');
  • add_action('admin_init','wp_auth_check_load');
  • add_action('admin_init','wp_plugin_update_rows');
  • add_action('admin_init','wp_schedule_update_network_counts');
  • add_action('admin_init','wp_theme_update_rows');
  • add_action('admin_menu','_add_post_type_submenus');
  • add_action('admin_menu','_add_themes_utility_last',101);
  • add_action('admin_menu',array($this,'init'));
  • add_action('admin_menu','twentyeleven_theme_options_add_page');
  • add_action('_admin_menu','wp_widgets_add_menu');
  • add_action('admin_notices','default_password_nag');
  • add_action('admin_notices','hello_dolly');
  • add_action('admin_notices','maintenance_nag');
  • add_action('admin_notices','new_user_email_admin_notice');
  • add_action('admin_notices','site_admin_notice');
  • add_action('admin_notices','twentythirteen_upgrade_notice');
  • add_action('admin_notices','update_nag',3);
  • add_action('admin_page_access_denied','_access_denied_splash',99);
  • add_action('admin_page_access_denied','wp_link_manager_disabled_message');
  • add_action('admin_print_footer_scripts',array(__CLASS__,'editor_js'),50);
  • add_action('admin_print_footer_scripts',array('WP_Internal_Pointers','pointer_'.$pointer));
  • add_action('admin_print_footer_scripts','wp_auth_check_html',5);
  • add_action('admin_print_footer_scripts','_wp_footer_scripts');
  • add_action("admin_print_scripts-$page",array(&$this,'js_includes'));
  • add_action('admin_print_scripts','print_head_scripts',20);
  • add_action('admin_print_styles-appearance_page_custom-header','twentythirteen_fonts');
  • add_action('admin_print_styles-appearance_page_custom-header','twentytwelve_custom_header_fonts');
  • add_action('admin_print_styles-appearance_page_theme_options','twentyeleven_admin_enqueue_scripts');
  • add_action("admin_print_styles-$page",array(&$this,'css_includes'));
  • add_action('admin_print_styles','print_admin_styles',20);
  • add_action("after_plugin_row_$plugin_file",'wp_plugin_update_row',10,2);
  • add_action('after_setup_theme',array($this,'after_setup_theme'));
  • add_action('after_setup_theme','my_child_theme_setup');
  • add_action('after_setup_theme','twentyeleven_setup');
  • add_action('after_setup_theme','twentyten_setup');
  • add_action('after_setup_theme','twentythirteen_custom_header_setup');
  • add_action('after_setup_theme','twentythirteen_setup');
  • add_action('after_setup_theme','twentytwelve_custom_header_setup');
  • add_action('after_setup_theme','twentytwelve_setup');
  • add_action('after_switch_theme','twentythirteen_switch_theme',10,2);
  • add_action('after_switch_theme','_wp_sidebars_changed');
  • add_action("after_theme_row_$theme",'wp_theme_update_row',10,2);
  • add_action('attachment_submitbox_misc_actions','attachment_submitbox_metadata');
  • add_action('begin_fetch_post_thumbnail_html','_wp_post_thumbnail_class_filter_add');
  • add_action('check_comment_flood','check_comment_flood_db',10,3);
  • add_action('comment_form','wp_comment_form_unfiltered_html_nonce');
  • add_action('comment_post',array($this,'flush_widget_cache'));
  • add_action('_core_updated_successfully','_redirect_to_about_wordpress');
  • add_action('customize_controls_enqueue_scripts',array($this,'enqueue_control_scripts'));
  • add_action('customize_controls_enqueue_scripts','wp_plupload_default_settings');
  • add_action('customize_controls_init',array($this,'prepare_control'),5);
  • add_action('customize_controls_init',array($this,'prepare_controls'));
  • add_action('customize_controls_print_footer_scripts','_wp_footer_scripts');
  • add_action('customize_controls_print_scripts','print_head_scripts',20);
  • add_action('customize_controls_print_styles','print_admin_styles',20);
  • add_action('customize_preview_init','twentyeleven_customize_preview_js');
  • add_action('customize_preview_init','twentythirteen_customize_preview_js');
  • add_action('customize_preview_init','twentytwelve_customize_preview_js');
  • add_action('customize_register',array($this,'register_controls'));
  • add_action('customize_register','twentyeleven_customize_register');
  • add_action('customize_register','twentythirteen_customize_register');
  • add_action('customize_register','twentytwelve_customize_register');
  • add_action('deactivate_'.$file,$function);
  • add_action('delete_attachment','_delete_attachment_theme_mod');
  • add_action('deleted_post',array($this,'flush_widget_cache'));
  • add_action('deleted_post',array(&$this,'flush_widget_cache'));
  • add_action('delete_post','delete_get_calendar_cache');
  • add_action('delete_post','_update_blog_date_on_post_delete');
  • add_action('delete_post','_wp_delete_post_menu_item');
  • add_action('delete_term','_wp_delete_tax_menu_item');
  • add_action('do_feed_atom','do_feed_atom',10,1);
  • add_action('do_feed_rdf','do_feed_rdf',10,1);
  • add_action('do_feed_rss2','do_feed_rss2',10,1);
  • add_action('do_feed_rss','do_feed_rss',10,1);
  • add_action('do_pings','do_all_pings',10,1);
  • add_action('do_robots','do_robots');
  • add_action('edit_form_advanced',array($this,'maybe_run_ajax_cache'));
  • add_action('edit_form_after_title','edit_form_image_editor');
  • add_action('embed_defaults','twentythirteen_video_width');
  • add_action('end_fetch_post_thumbnail_html','_wp_post_thumbnail_class_filter_remove');
  • add_action('future_'.$post_type,'_future_post_hook',5,2);
  • add_action('importer_scheduled_cleanup','wp_delete_attachment');
  • add_action('in_admin_header','wp_admin_bar_render',0);
  • add_action('init',array($this,'init'),0);
  • add_action('init','check_theme_switched',99);
  • add_action('init','create_initial_post_types',0);//highestpriority
  • add_action('init','create_initial_taxonomies',0);//highestpriority
  • add_action('init','kses_init');
  • add_action('init','maybe_add_existing_user_to_blog');
  • add_action('init','ms_subdomain_constants');
  • add_action('init','_show_post_preview');
  • add_action('init','smilies_init',5);
  • add_action('init','wp_cron');
  • add_action('init','wp_schedule_update_checks');
  • add_action('init','wp_widgets_init',1);
  • add_action('install_plugins_dashboard','install_dashboard');
  • add_action('install_plugins_favorites','display_plugins_table');
  • add_action('install_plugins_favorites','install_plugins_favorites_form',9,0);
  • add_action('install_plugins_featured','display_plugins_table');
  • add_action('install_plugins_new','display_plugins_table');
  • add_action('install_plugins_popular','display_plugins_table');
  • add_action('install_plugins_pre_plugin-information','install_plugin_information');
  • add_action('install_plugins_search','display_plugins_table');
  • add_action('install_plugins_table_header','install_search_form',10,0);
  • add_action('install_plugins_upload','install_plugins_upload',10,1);
  • add_action('install_themes_dashboard','install_themes_dashboard');
  • add_action('install_themes_featured','display_themes');
  • add_action('install_themes_new','display_themes');
  • add_action('install_themes_pre_theme-information','install_theme_information');
  • add_action('install_themes_search','display_themes');
  • add_action('install_themes_table_header','install_theme_search_form',10,0);
  • add_action('install_themes_updated','display_themes');
  • add_action('install_themes_upload','install_themes_upload',10,1);
  • add_action('load-customize.php','twentythirteen_customize');
  • add_action("load-$page",array(&$this,'admin_load'));
  • add_action("load-$page",array(&$this,'handle_upload'),49);
  • add_action("load-$page",array(&$this,'take_action'),49);
  • add_action('load-plugins.php','wp_update_plugins');
  • add_action("load-$theme_page",'twentyeleven_theme_options_help');
  • add_action('load-themes.php','wp_update_themes');
  • add_action('load-update-core.php','wp_update_plugins');
  • add_action('load-update-core.php','wp_update_themes');
  • add_action('load-update.php','wp_update_plugins');
  • add_action('load-update.php','wp_update_themes');
  • add_action('login_footer','wp_print_footer_scripts',20);
  • add_action('login_head','wp_no_robots');
  • add_action('login_head','wp_print_head_scripts',9);
  • add_action('login_head','wp_shake_js',12);
  • add_action('login_init','send_frame_options_header',10,0);
  • add_action('media_buttons','media_buttons');
  • add_action('media_buttons','press_this_media_buttons');
  • add_action('media_upload_audio','wp_media_upload_handler');
  • add_action('media_upload_file','wp_media_upload_handler');
  • add_action('media_upload_image','wp_media_upload_handler');
  • add_action('media_upload_video','wp_media_upload_handler');
  • add_action('network_admin_notices','secret_salt_warning');
  • add_action('network_admin_notices','site_admin_notice');
  • add_action('network_admin_notices','update_nag',3);
  • add_action('personal_options_update','send_confirmation_on_profile_email');
  • add_action('phpmailer_init','fix_phpmailer_messageid');
  • add_action('plugins_loaded','_wp_customize_include');
  • add_action('plugins_loaded','wp_maybe_load_embeds',0);
  • add_action('plugins_loaded','wp_maybe_load_widgets',0);
  • add_action('post-html-upload-ui','media_upload_html_bypass');
  • add_action('post-plupload-upload-ui','media_upload_flash_bypass');
  • add_action('post_updated','wp_check_for_changed_slugs',12,3);
  • add_action('pre_post_update',array($this,'delete_oembed_caches'));
  • add_action('profile_update','default_password_nag_edit_user',10,2);
  • add_action('publish_future_post','check_and_publish_future_post',10,1);
  • add_action('publish_post','_publish_post_hook',5,1);
  • add_action('publish_post','update_posts_count');
  • add_action('sanitize_comment_cookies','sanitize_comment_cookies');
  • add_action('sanitize_user','strtolower');
  • add_action('save_post',array($this,'flush_widget_cache'));
  • add_action('save_post',array(&$this,'flush_widget_cache'));
  • add_action('save_post','delete_get_calendar_cache');
  • add_action('set_comment_cookies','wp_set_comment_cookies',10,2);
  • add_action('set_current_user','kses_init');
  • add_action('setup_theme',array($this,'setup_theme'));
  • add_action('setup_theme','preview_theme');
  • add_action('shortcode_atts_video','twentythirteen_video_width');
  • add_action('shutdown',array($this,'customize_preview_signature'),1000);
  • add_action('shutdown','wp_ob_end_flush_all',1);
  • add_action('signup_hidden_fields','signup_nonce_fields');
  • add_action('switch_theme',array($this,'flush_widget_cache'));
  • add_action('switch_theme',array(&$this,'flush_widget_cache'));
  • add_action('template_redirect','maybe_redirect_404');
  • add_action('template_redirect','redirect_canonical');
  • add_action('template_redirect','twentythirteen_content_width');
  • add_action('template_redirect','twentytwelve_content_width');
  • add_action('template_redirect','_wp_admin_bar_init',0);
  • add_action('template_redirect','wp_old_slug_redirect');
  • add_action('template_redirect','wp_redirect_admin_locations',1000);
  • add_action('template_redirect','wp_shortlink_header',11,0);
  • add_action('transition_comment_status',array($this,'flush_widget_cache'));
  • add_action('transition_post_status','__clear_multi_author_cache');
  • add_action('transition_post_status','_transition_post_status',5,3);
  • add_action('transition_post_status','_update_blog_date_on_post_publish',10,3);
  • add_action('transition_post_status','_update_term_count_on_transition_post_status',10,3);
  • add_action('transition_post_status','_wp_auto_add_pages_to_menu',10,3);
  • add_action('uninstall_'.$file,$callable);
  • add_action('update_network_counts','wp_update_network_counts');
  • add_action('update_option_blog_public','update_blog_public',10,2);
  • add_action('update_option_gmt_offset','delete_get_calendar_cache');
  • add_action('update_option_home','update_home_siteurl',10,2);
  • add_action('update_option_new_admin_email','update_option_new_admin_email',10,2);
  • add_action('update_option_page_on_front','update_home_siteurl',10,2);
  • add_action('update_option_siteurl','update_home_siteurl',10,2);
  • add_action('update_option_start_of_week','delete_get_calendar_cache');
  • add_action('upgrader_scheduled_cleanup','wp_delete_attachment');
  • add_action('upload_ui_over_quota','multisite_over_quota_message');
  • add_action('user_register',array('WP_Internal_Pointers','dismiss_pointers_for_new_users'));
  • add_action('welcome_panel','wp_welcome_panel');
  • add_action('widgets_init',array($this,'_register_widgets'),100);
  • add_action('widgets_init','twentyeleven_widgets_init');
  • add_action('widgets_init','twentyten_remove_recent_comments_style');
  • add_action('widgets_init','twentyten_widgets_init');
  • add_action('widgets_init','twentythirteen_widgets_init');
  • add_action('widgets_init','twentytwelve_widgets_init');
  • add_action('wp_ajax_customize_save',array($this,'save'));
  • add_action('wp_ajax_'.$_GET['action'],'wp_ajax_'.str_replace('-','_',$_GET['action']),1);
  • add_action('wp_ajax_nopriv_heartbeat','wp_ajax_nopriv_heartbeat',1);
  • add_action('wp_ajax_'.$_POST['action'],'wp_ajax_'.str_replace('-','_',$_POST['action']),1);
  • add_action('wp_ajax_set-background-image',array($this,'wp_set_background_image'));
  • add_action('wp_before_admin_bar_render','wp_customize_support_script');
  • add_action('wp_default_scripts','wp_default_scripts');
  • add_action('wp_default_styles','wp_default_styles');
  • *add_action('wp_enqueue_scripts','mytheme_dequeue_fonts',11);
  • add_action('wp_enqueue_scripts','twentyeleven_enqueue_color_scheme');
  • add_action('wp_enqueue_scripts','twentythirteen_fonts');
  • add_action('wp_enqueue_scripts','twentythirteen_scripts_styles');
  • add_action('wp_enqueue_scripts','twentytwelve_scripts_styles');
  • add_action('wp_footer',array(__CLASS__,'enqueue_scripts'),1);
  • add_action('wp_footer',array($this,'customize_preview_settings'),20);
  • add_action('wp_footer','wp_admin_bar_render',1000);
  • add_action('wp_footer','wp_print_footer_scripts',20);
  • add_action('wp_footer','wp_print_media_templates');
  • add_action('wp_head','adjacent_posts_rel_link_wp_head',10,0);
  • add_action('wp_head',$args[0]['wp-head-callback']);
  • add_action('wp_head',array($this,'customize_preview_base'));
  • add_action('wp_head',array($this,'customize_preview_html5'));
  • add_action('wp_head',array($this,'recent_comments_style'));
  • add_action('wp_head','do_activate_header');
  • add_action('wp_head','do_signup_header');
  • add_action('wp_head','feed_links',2);
  • add_action('wp_head','feed_links_extra',3);
  • add_action('wp_head',$header_callback);
  • add_action('wp_head','locale_stylesheet');
  • add_action('wp_head','noindex',1);
  • add_action('wp_head','rel_canonical');
  • add_action('wp_head','rsd_link');
  • add_action('wp_head','twentyeleven_print_link_color_style');
  • add_action('wp_head','wlwmanifest_link');
  • add_action('wp_head','wp_admin_bar_header');
  • add_action('wp_head','wp_enqueue_scripts',1);
  • add_action('wp_head','wp_generator');
  • add_action('wp_head','wpmu_activate_stylesheet');
  • add_action('wp_head','wpmu_signup_stylesheet');
  • add_action('wp_head','wp_no_robots');
  • add_action('wp_head','wp_print_head_scripts',9);
  • add_action('wp_head','wp_print_styles',8);
  • add_action('wp_head','wp_shortlink_wp_head',10,0);
  • add_action('wp_insert_post','wp_save_post_revision',10,1);
  • add_action('wp_loaded',array($this,'wp_loaded'));
  • add_action('wp_loaded','_custom_header_background_just_in_time');
  • add_action('wpmu_activate_user','add_new_user_to_blog',10,3);
  • add_action('wpmueditblogaction','upload_space_setting');
  • add_action('wpmu_new_blog','newblog_notify_siteadmin',10,2);
  • add_action('wpmu_new_blog','wpmu_log_new_registrations',10,2);
  • add_action('wpmu_new_user','newuser_notify_siteadmin');
  • add_action('wp_print_footer_scripts',array(__CLASS__,'editor_js'),50);
  • add_action('wp_print_footer_scripts','wp_auth_check_html',5);
  • add_action('wp_print_footer_scripts','_wp_footer_scripts');
  • add_action('wp_redirect_status',array($this,'wp_redirect_status'),1000);
  • add_action('wp_scheduled_auto_draft_delete','wp_delete_auto_drafts');
  • add_action('wp_scheduled_delete','wp_scheduled_delete');
  • add_action('wp_update_plugins','wp_update_plugins');
  • add_action('wp_update_themes','wp_update_themes');
  • add_action('wp_version_check','wp_version_check');


Monday, July 11, 2011


Visualize Backtrace seems to be interesting :
http://drupal.org/project/visualize_backtrace


The drupal system composes a function name based on the form_id variable and the suffix of _validate, then it marks a bit as true in the form object, but does not store the whole function. This saves memory but would be slower than storing the function directly or wrapped in a call context in the hash, we can expect to call it later anyway.
if (!isset($form['#validate'])) {    if (function_exists($form_id .'_validate')) {      $form['#validate'] = array($form_id .'_validate');    }  }


later it does more checks,
    if (isset($elements['#needs_validation'])) 

This shows you that there are more callbacks available.  http://api.drupal.org/api/drupal/includes--form.inc/function/_form_validate/6 .



This is the callback function for the submit,
 $function($form, $form_state);

Thursday, October 7, 2010

Wp problem

Invite Friends Invite friends on buddypress social network from MSN, gmail, facebokk and twitter. It can easily be added to a page using the code [invitefriends] or from BuddyPress Bar : MyAccount/Friends/Invite Friends

Version 0.8 | By Giovanni Caputo

Fatal error: Call to undefined function bp_core_add_subnav_item() in /data/web/4d/15/05/flossk.tuxfamily.org/htdocs/wordpress/wp-content/plugins/invitefriends-plug-in/bp-invitefriends.php on line 49

Saturday, October 2, 2010

Plan : drupal porting of facebook connect

I am working on a drupal 7 site to help upload content to wikimedia :

I want to make it easy for people on facebook, to post pictures to wikimedia commons
and have a way to integrate drupal as a facebook app.

for things like wikipedia, openstreetmap etc.
Many people in the developing world use facebook as a primary means of communication
like in africa or the balkans they all are on facebook.
we can make it easy for them to contribute to wikipedia or osm via facebook.

http://fmtyewtk.blogspot.com/2010/09/new-commonswikimediaorg-picture-content.htm

The plan is to install the coder module to help port the fb connect to 7:
http://drupal.org/project/coder
http://drupal.org/node/361112

The facebook connect code is here :
http://drupal.org/project/fbconnect
http://github.org/vectoroc/fbconnect



Anyone want to help?

Wednesday, July 7, 2010

gosa stumble and catch!

apt-get install gosa

http://xhema.flossk.org:8084/gosa/

Fatal error: Call to undefined function get_gosa_version() in /usr/share/gosa/include/php_setup.inc on line 80

https://bugs.launchpad.net/ubuntu/+source/gosa/+bug/370505

Fixed with this apt/sources.list entry:
  deb http://oss.gonicus.de/pub/gosa/debian-etch/ ./

Invite friends wordpress plugin broken

is broken :
Catchable fatal error: Object of class WP_Error could not be converted to string in /data/web/4d/15/05/flossk.tuxfamily.org/htdocs/wordpress/wp-content/plugins/invite-friends/pages/inviteform.php on line 114

Monday, July 5, 2010

Open Graph Failed

Open Graph Failed
Fatal error: Call to undefined function has_post_thumbnail() in /data/web/4d/15/05/flossk.tuxfamily.org/htdocs/wordpress/wp-content/plugins/opengraph/opengraph.php on line 107

Url:
http://flossk.tuxfamily.org/wordpress/2010/07/04/14/




Solution: Deactivated.