Skip to content

Instantly share code, notes, and snippets.

@hykw hykw/README.md
Last active Mar 13, 2018

Embed
What would you like to do?
init

WordPress プラグインバージョン確認スクリプト

指定ディレクトリの WordPress にインストールされてるプラグインのバージョンと、WordPress.org 上のプラグインのバージョンや最終更新日などを表示する

Usage

./list_wp_plugins.sh WordPressインストールディレクトリ

例)
./list_wp_plugins.sh /var/www/wordpress/
#!/bin/sh
SCRIPT_DIR=$(cd $(dirname $(readlink -f $0 || echo $0));pwd -P)
cd $SCRIPT_DIR
WP_PATH=$1
if [ $# -lt 1 ]; then
echo "Usage: $0 Wordpress path"
echo
echo "e.g."
echo " $0 /var/www/wordpress/"
echo
exit
fi
function search_wordpress_org()
{
TMP2=`mktemp`
NAME=$1
WP_PATH=$2
wp plugin search "$NAME" --path=$WP_PATH --skip-themes --skip-plugins --format=csv --fields=name,slug,version,tested,last_updated 2>&1 > $TMP2
MATCH="`./retrieve_match_line.py $TMP2 $NAME`"
MATCH_COUNT=`echo $MATCH|wc -l`
if [ $MATCH_COUNT -eq 0 ]; then
echo "---,---,---"
else
echo $MATCH
fi
rm $TMP2
}
##################################################
TMP=`mktemp`
wp plugin list --skip-themes --path=$WP_PATH --fields=name,version --format=csv 2>&1 > $TMP
echo "slug, current_ver, new_version, tested wp, last_updated"
for x in `cat $TMP | grep -v ^name`
do
NAME="`echo $x | cut -d, -f1`"
VERSION=`echo $x | cut -d, -f2`
SEARCH_RESULT=`search_wordpress_org $NAME $WP_PATH`
NEW_VERSION=`echo $SEARCH_RESULT|cut -d, -f1`
TESTED=`echo $SEARCH_RESULT|cut -d, -f2`
LAST_UPDATED=`echo $SEARCH_RESULT|cut -d, -f3`
echo "$NAME, $VERSION, $NEW_VERSION, $TESTED, $LAST_UPDATED"
done
rm $TMP
#!/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, print_function, absolute_import, unicode_literals)
import re
import sys
args = sys.argv
tmp_file = args[1]
search_name = args[2]
with open(tmp_file, 'r') as f:
for line in f:
if re.match(r"^name,", line):
continue
name, slug, version, tested, last_updated = line.decode('utf-8').strip().split(",", 4)
if slug != search_name:
continue
last_updated_trim = last_updated.replace('"', '')
print("{0},{1},{2}".format(version, tested, last_updated_trim))
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.