Разработка плагина для wordpress

22
Разработка плагина для WordPress Amin Benarieb

Upload: amin-benarieb

Post on 22-Jun-2015

82 views

Category:

Technology


0 download

DESCRIPTION

Разработка плагина для Word press

TRANSCRIPT

Page 1: Разработка плагина для Wordpress

Разработка плагина для WordPress

Amin Benarieb

Page 2: Разработка плагина для Wordpress

Разработка Публикация

сodex.wordpress.org/Написание_плагина

Page 3: Разработка плагина для Wordpress

Структура/wp-content/plugins/push_notifications/ ->css/ ->js/ ->img/ ->languages/ ->... ->push_notifications.php ->readme.txt

Page 4: Разработка плагина для Wordpress

<?php /* Plugin Name: Название плагина Plugin URI: http://страница_с_описанием_плагина_и_его_обновлений Description: Краткое описание плагина. Version: Номер версии плагина, например: 1.0 Author: Имя автора плагина Author URI: http://страница_автора_плагина !!Copyright ГОД ИМЯ_АВТОРА_ПЛАГИНА (email: E-MAIL_АВТОРА) !This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. !This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. !You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ?>

Page 5: Разработка плагина для Wordpress

/* Plugin Name: Push Notifications iOS Description: This plugin allows you to send Push Notifications directly from your WordPress site to your iOS app. Author: Amin Benarieb Version: 0.3 License: GPLv2 or later !© 2014 Amin Benarieb (email: [email protected]) !... */ !

Page 6: Разработка плагина для Wordpress

Зацепки (Hook) плагина

register_activation_hook( __FILE__, 'push_notifications_install'); register_deactivation_hook( __FILE__, 'push_notifications_uninstall');

Page 7: Разработка плагина для Wordpress

Зацепки (Hook) плагина

add_action('admin_head', 'push_notifications_css'); add_action('admin_menu', 'push_notifications_admin_pages');

Действия (actions):

Page 8: Разработка плагина для Wordpress

Зацепки (Hook) плагина

add_menu_page( $page_title, $menu_title, $capability, $menu_slug,//site.ru/wp-admin/admin.php?page=$menu_slug $function, $icon_url, $position

);

http://codex.wordpress.org/Function_Reference/add_menu_page

Page 9: Разработка плагина для Wordpress

Зацепки (Hook) плагинаfunction push_notifications_admin_pages() { ....

add_menu_page( 'iOS Push Notifications', 'iOS Push Notifications', 'manage_options', 'push_notifications', 'push_notifications_options_page', plugins_url( '/push-notifications-ios/img/icon.png' ), 40 );

}

Page 10: Разработка плагина для Wordpress
Page 11: Разработка плагина для Wordpress

Зацепки (Hook) плагина

add_filter( 'page_template', 'push_notifications_page_template' ); add_filter('upload_mimes', 'add_custom_upload_mimes');

Фильтры (filters):

Page 12: Разработка плагина для Wordpress

Зацепки (Hook) плагина

function add_custom_upload_mimes($existing_mimes){ ! $existing_mimes['pem'] = 'application/octet-stream'; ! return $existing_mimes; !} !function push_notifications_page_template( $page_template ){ if ( is_page( "register_user_device" ) ) $page_template = dirname( __FILE__ ) . '/register_user_device.php'; return $page_template; }

Page 13: Разработка плагина для Wordpress

Публикация плагинаhttp://wordpress.org/plugins/add/

http://wordpress.org/plugins/about/

Page 14: Разработка плагина для Wordpress

zedamin, !Your plugin hosting request has been approved. !Within one hour, you will have access to your SVN repository at !http://plugins.svn.wordpress.org/.... !with your WordPress.org username and password (the same one you use on the forums). !Here's some handy links to help you get started. !Using Subversion with the WordPress Plugins Directory http://wordpress.org/plugins/about/svn/ !FAQ about the WordPress Plugins Directory http://wordpress.org/plugins/about/faq/ !WordPress Plugins Directory readme.txt standard http://wordpress.org/plugins/about/readme.txt !readme.txt validator: http://wordpress.org/plugins/about/validator/ !Enjoy!

Page 15: Разработка плагина для Wordpress

http://versionsapp.com/

http://tortoisesvn.net/

Клиенты систем управления версиями (SVN)

Page 16: Разработка плагина для Wordpress
Page 17: Разработка плагина для Wordpress

=== Push Notification iOS === Contributors: zedamin Tags: push notifications, iOS, iPhone, iPad, iPod Touch Requires at least: 3.6 Tested up to: 3.7.1 Stable tag: 0.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html !This plugin allows you to send Push Notifications directly from your WordPress site to your iOS app. !== Description == !This plugin allows you to send notifications directly from your WordPress site with payload (JSON) to all devices, that have installed your app to notify users about something new. !Now, go to Installation section to find out how to install and use plugin. !!== Installation == !This section describes how to install the plugin and get it working. !!1. Upload `push_notifications_ios` to the `/wp-content/plugins/` directory 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Plugin creates two tables: first for list of devises, second for settings 4. Upload your .pem certificates (if you don't know to create them follow link http://stackoverflow.com/questions/1762555/creating-pem-file-for-apns#_=_) 5. Then you need to write some lines of code in your ios app, follow link https://bitbucket.org/zedamin/push-notifications-ios/wiki/Home 7. Enjoy! !== Changelog == != 0.2 = First beta version.

Page 18: Разработка плагина для Wordpress
Page 19: Разработка плагина для Wordpress
Page 20: Разработка плагина для Wordpress
Page 21: Разработка плагина для Wordpress

http://wordpress.org/plugins/about/validator/

http://wordpress.org/plugins/about/readme.txt

Page 22: Разработка плагина для Wordpress

Спасибо за внимание