Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus committed Jan 7, 2017
1 parent cfa7583 commit 55f3326
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 113 deletions.
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function( grunt ) {

addtextdomain: {
options: {
textdomain: 'medium-remove-cross-links',
textdomain: 'remove-medium-cross-links',
},
target: {
files: {
Expand All @@ -30,8 +30,8 @@ module.exports = function( grunt ) {
target: {
options: {
domainPath: '/languages',
mainFile: 'medium-remove-cross-links.php',
potFilename: 'medium-remove-cross-links.pot',
mainFile: 'remove-medium-cross-links.php',
potFilename: 'remove-medium-cross-links.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Remove Medium Cross Links #
**Contributors:** tangrufus, typisttech
**Tags:** medium
**Donate link:** https://www.typist.tech/donate/remove-medium-cross-links
**Requires at least:** 4.0
**Tested up to:** 4.7
**Stable tag:** trunk
**License:** GPLv2
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Remove Medium cross links footer from WordPress.

## Description ##
### Features ###
* Remove Medium cross links footer from WordPress
* It keeps the cross links footer on Medium.com

Check Typist Tech blog about [Cross Posting WordPress to Medium without Hurting SEO](https://www.typist.tech/cross-posting-wordpress-to-medium-without-hurting-seo/)

### Things you need to know ###

* You need the official [Medium plugin](https://wordpress.org/plugins/medium/) .
* This plugin was not built by Medium.

If you have written an article about `Remove Medium Cross Links`, do [let me know](https://www.typist.tech/contact-us/).

### Who make this plugin? ###

[Tang Rufus](mailto://[email protected]), a freelance developer for hire.
I make [Typist Tech](https://www.typist.tech/) also.


## Installation ##
1. Download the plugin.
1. Go to the WordPress Plugin menu and activate it.
1. That's it!

## Changelog ##
### 1.0.0 ###
* Initial release
210 changes: 210 additions & 0 deletions bin/svn-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#!/bin/bash
# Given a svn-url file one directory up, export the latest git commits to the specified SVN repo.
# Create a git release tag from the version specified in the plugin file.
# Author: Weston Ruter (@westonruter)

set -e

cd "$( dirname $0 )"
dev_lib_dir=$(pwd)
cd ..


if [ -e .dev-lib ]; then
source .dev-lib
elif [ -e .ci-env.sh ]; then
source .ci-env.sh
fi
if [ -e svn-url ]; then
SVN_URL=$(cat svn-url)
fi

if [ -z "$SVN_URL" ]; then
echo "Error: Missing SVN_URL" >&2
exit 1
fi

force=
while getopts 'f' option; do
case $option in
f)
force=1
;;
esac
done

current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ $current_branch != 'master' ]; then
echo "Please checkout the master branch"
exit 1
fi

if [ -n "$(git status -s -uno)" ] && [ -z "$force" ]; then
git status
echo "Error: Git state has modified or staged files. Commit or reset, or supply -f" >&2
exit 1
fi

git_root=$(pwd)

if [ -e readme.txt ]; then
$dev_lib_dir/generate-markdown-readme
git add readme.md
fi
if [ -n "$(git status --porcelain readme.md)" ]; then
echo "Please commit (--amend?) the updated readme.md"
exit 1
fi

git pull --ff-only origin master
git push origin master
git_root_hash=$(md5sum <<< "$git_root" | cut -c1-32)
plugin_uniq_slug="$(basename "$git_root")-$git_root_hash"
lock_file="/tmp/$plugin_uniq_slug.lock"
svn_tmp_repo_dir="/tmp/svn-$plugin_uniq_slug"
git_tmp_repo_dir="/tmp/git-$plugin_uniq_slug"
echo "Temp SVN dir: $svn_tmp_repo_dir"
echo "Temp Git dir: $git_tmp_repo_dir"

for php in *.php; do
if grep -q 'Plugin Name:' $php && grep -q 'Version:' $php; then
plugin_version=$(cat $php | grep 'Version:' | sed 's/.*Version: *//')
fi
done

if [ -z "$plugin_version" ]; then
echo "Unable to find plugin version"
exit 1
fi

if ! grep -q "$plugin_version" readme.txt; then
echo "Please update readme.txt to include $plugin_version in changelog"
exit 1
fi

if git show-ref --tags --quiet --verify -- "refs/tags/$plugin_version"; then
has_tag=1
fi

if [ -n "$has_tag" ] && [ -z "$force" ]; then
echo "Plugin version $plugin_version already tagged. Please bump version and try again, or supply -f"
exit 1
fi

# Clean up existing Git and SVN repos
if [ -e "$lock_file" ] || ( [ -e "$svn_tmp_repo_dir" ] && [ ! -e "$svn_tmp_repo_dir/.svn" ] ); then
echo "Cleanup $svn_tmp_repo_dir"
rm -rf "$svn_tmp_repo_dir"
fi
if [ -e "$lock_file" ] || ( [ -e "$git_tmp_repo_dir" ] && [ ! -e "$git_tmp_repo_dir/.git" ] ); then
echo "Cleanup $git_tmp_repo_dir"
rm -rf "$git_tmp_repo_dir"
fi

touch "$lock_file"

# SVN: Checkout or update
if [ ! -e $svn_tmp_repo_dir ]; then
svn checkout $SVN_URL $svn_tmp_repo_dir
cd $svn_tmp_repo_dir
else
cd $svn_tmp_repo_dir
svn up
fi

# Git: Clone or pull
if [ ! -e $git_tmp_repo_dir ]; then
git clone $git_root $git_tmp_repo_dir
cd $git_tmp_repo_dir
else
cd $git_tmp_repo_dir
git pull
fi

# rsync all committed files from the Git repo to SVN
rsync -avz --delete --delete-excluded \
--exclude '/.david-dev' \
--exclude '/package.json' \
--exclude '/contributing.md' \
--exclude '/composer.json' \
--exclude '/Gruntfile.js' \
--exclude '/readme.md' \
--exclude '/.ci-env.sh' \
--exclude '/.dev-lib' \
--exclude '/.coveralls.yml' \
--exclude '/.git*' \
--exclude '/.jscsrc' \
--exclude '/.eslintrc' \
--exclude '/.jshint*' \
--exclude '/.mailmap' \
--exclude '/.travis.yml' \
--exclude '/assets' \
--exclude '/dev-lib' \
--exclude '/svn-url' \
--exclude '/tests' \
--exclude 'phpunit.xml*' \
--exclude 'phpcs.ruleset.xml' \
$git_tmp_repo_dir/ $svn_tmp_repo_dir/trunk/
if [ -e $git_tmp_repo_dir/assets/ ]; then
mkdir -p $svn_tmp_repo_dir/assets/
rsync -avz --delete --include='*.jpg' --include='*.jpeg' --include='*.png' --include='*.svg' --exclude='*' --delete-excluded $git_tmp_repo_dir/assets/ $svn_tmp_repo_dir/assets/
fi
cd $svn_tmp_repo_dir

if svn status | grep -s '^!'; then
svn status | grep '^!' | awk '{print $2}' | xargs svn delete --force
fi
svn add --force trunk/ --auto-props --parents --depth infinity -q
if [ -e assets/ ]; then
svn add --force assets/ --auto-props --parents --depth infinity -q
fi

mkdir -p tags
if [ -e tags/$plugin_version ]; then
svn rm --force tags/$plugin_version
fi
mkdir -p tags/$plugin_version
rsync -avz trunk/ tags/$plugin_version/
svn add --force tags/$plugin_version --auto-props --parents --depth infinity -q

# Add mime types
while read extension mime_type; do
if [[ "$extension" = \#* ]] || [ -z "$extension" ] || [ -z "$mime_type" ]; then
continue
fi
echo "Set mime-type $mime_type on all $extension files..."

OLD_IFS="$IFS"
IFS=$'\n'
for file in $( find . -name "*.$extension" ); do
if svn info "$file" 1>/dev/null 2>&1; then
svn propset svn:mime-type "$mime_type" "$file"
fi
done
IFS="$OLD_IFS"
done < "$dev_lib_dir/mime-types.csv"

svn_commit_file=/tmp/svn-commit-msg
git --git-dir $git_root/.git log -1 --format="Update to commit %h from $(git --git-dir $git_root/.git config --get remote.origin.url)" > $svn_commit_file

svn status
echo
echo "SVN Commit message:"
cat $svn_commit_file
echo

echo "Hit enter to proceed with SVN commit and Git tag"
read OK

if [ -z "$has_tag" ]; then
cd "$git_root"
echo "Tagging plugin version $plugin_version"
git tag "$plugin_version" master
git push origin "$plugin_version"
else
echo "Skipping plugin tag $plugin_version since already exists"
fi

cd $svn_tmp_repo_dir
svn commit -F $svn_commit_file
rm "$lock_file"
29 changes: 21 additions & 8 deletions medium-remove-cross-links.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
<?php
/**
* Plugin Name: Medium Remove Cross Links
* Plugin URI: PLUGIN SITE HERE
* Description: PLUGIN DESCRIPTION HERE
* Author: YOUR NAME HERE
* Author URI: YOUR SITE HERE
* Text Domain: medium-remove-cross-links
* Plugin Name: Remove Medium Cross Links
* Plugin URI: https://github.com/TangRufus/remove-medium-cross-links
* Description: Remove cross links from medium plugin
* Author: Tang Rufus
* Author URI: https://www.typist.tech/
* Text Domain: remove-medium-cross-links
* Domain Path: /languages
* Version: 0.1.0
* Version: 1.0.0
*
* @package Medium_Remove_Cross_Links
* @package Remove_Medium_Cross_Links
*/

/**
* Remove cross link action.
*
* @return void
*/
function remove_medium_cross_links() {
remove_action( 'init', array( 'Medium_Site', 'init' ) );
}

if ( ! is_admin() ) {
add_action( 'init', 'remove_medium_cross_links', 5 );
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

{
"name": "medium-remove-cross-links",
"name": "remove-medium-cross-links",
"version": "0.1.0",
"main": "Gruntfile.js",
"author": "YOUR NAME HERE",
"author": "Tang Rufus",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-wp-i18n": "~0.5.0",
Expand Down
Loading

0 comments on commit 55f3326

Please sign in to comment.