Skip to content

Commit

Permalink
Fix work on php5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
utahta committed Jul 17, 2017
1 parent 1f97668 commit 0f510eb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions dockerfiles/php53/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DEBUG: 1

volumes:
db_data_php53:
2 changes: 0 additions & 2 deletions src/WpSocialBookmarkingLight/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public function save(array $data)
'button_type' => $data['gree_button_type'],
'button_size' => $data['gree_button_size']
),
'evernote' => array('button_type' => $data['evernote_button_type']),
'tumblr' => array('button_type' => $data['tumblr_button_type']),
'atode' => array('button_type' => $data['atode_button_type']),
'google_plus_one' => array(
Expand Down Expand Up @@ -228,7 +227,6 @@ private function defaultOption()
'button_type' => '4',
'button_size' => '16'
),
'evernote' => array('button_type' => 'article-clipper'),
'tumblr' => array('button_type' => '1'),
'atode' => array('button_type' => 'iconsja'),
'google_plus_one' => array(
Expand Down
20 changes: 11 additions & 9 deletions src/WpSocialBookmarkingLight/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ public function getBuilder()
/**
* Initialize wp actions
*/
public function init()
public static function init()
{
add_action('init', function() {
add_action('wp_head', array($this, 'head'));
add_action('wp_footer', array($this, 'footer'));
add_filter('the_content', array($this, 'theContent'));
add_action('admin_menu', array($this, 'adminMenu'));
$plugin = new Plugin();
add_action('wp_head', array($plugin, 'head'));
add_action('wp_footer', array($plugin, 'footer'));
add_filter('the_content', array($plugin, 'theContent'));
add_action('admin_menu', array($plugin, 'adminMenu'));
});
}

Expand Down Expand Up @@ -100,17 +101,18 @@ public function theContent($content)
public function adminMenu()
{
if( function_exists('add_options_page') ){
$admin = $this->admin;
$page = add_options_page('WP Social Bookmarking Light',
'WP Social Bookmarking Light',
'manage_options',
__FILE__,
function () {
echo $this->admin->page();
function () use($admin) {
echo $admin->page();
});
add_action('admin_print_styles-' . $page, array($this->admin, 'enqueueStyles'));
add_action('admin_print_scripts-' . $page, array($this->admin, 'enqueueScripts'));
add_action('admin_head-' . $page, function () {
echo $this->admin->head();
add_action('admin_head-' . $page, function () use($admin) {
echo $admin->head();
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/WpSocialBookmarkingLight/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ private function link($url, $alt, $icon, $width, $height, $blank = true)
*/
public function invokeService($service)
{
$method = str_replace('_', '', ucwords($service, '_')); // snake_case to camelCase
// snake_case to camelCase
$method = str_replace('_', "\t", $service);
$method = ucwords($method); // for php 5.3
$method = str_replace("\t", '', $method);
return $this->$method();
}

Expand Down
3 changes: 1 addition & 2 deletions wp-social-bookmarking-light.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@
/**
* initialize
*/
$wpSocialBookmarkingLight = new \WpSocialBookmarkingLight\Plugin();
$wpSocialBookmarkingLight->init();
\WpSocialBookmarkingLight\Plugin::init();

0 comments on commit 0f510eb

Please sign in to comment.