Version Description
Download this release
Release Info
Developer | themeisle |
Plugin | Contact Form & SMTP Plugin for WordPress by PirateForms |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.2.1
- CHANGELOG.md +4 -1
- bin/deploy.sh +71 -0
- bin/install-dependencies.sh +40 -0
- bin/install-wp-tests.sh +127 -0
- bin/prepare-deploy.sh +46 -0
- css/front.css +1 -1
- inc/settings.php +12 -2
- inc/widget.php +4 -1
- pirate-forms.php +30 -19
- tests/bootstrap.php +34 -0
- tests/test-pirate-forms.php +21 -0
CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
2 |
|
3 |
|
4 |
|
5 |
-
Update readme.txt
|
1 |
|
2 |
+
### v1.2.0 - 2017-05-08
|
3 |
+
**Changes:**
|
4 |
+
- Changed sent email format to a HTML type
|
5 |
+
|
6 |
|
7 |
|
8 |
|
|
bin/deploy.sh
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# We run this just one time, for a first job from the buid and just at once after_deploy hook.
|
4 |
+
if ! [ $AFTER_DEPLOY_RUN ] && [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then
|
5 |
+
|
6 |
+
# Flag the run in order to not be trigged again on the next after_deploy.
|
7 |
+
export AFTER_DEPLOY_RUN=1;
|
8 |
+
echo " Started deploy script. ";
|
9 |
+
|
10 |
+
# Setup git username and email.
|
11 |
+
|
12 |
+
git config user.name "selul"
|
13 |
+
git config user.email ${GITHUB_EMAIL}
|
14 |
+
git fetch
|
15 |
+
|
16 |
+
# Check if we already have a tag with this version.
|
17 |
+
if ! git rev-parse "v$THEMEISLE_VERSION" >/dev/null 2>&1
|
18 |
+
then
|
19 |
+
|
20 |
+
# Send changelog changes to git.
|
21 |
+
git checkout $MASTER_BRANCH
|
22 |
+
git add -v .
|
23 |
+
|
24 |
+
# We use [skip ci] in message to prevent this commit to trigger the build.
|
25 |
+
git commit -a -m "[AUTO][skip ci] Updating changelog for v"$THEMEISLE_VERSION
|
26 |
+
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" HEAD:$MASTER_BRANCH
|
27 |
+
|
28 |
+
# Tag the new release.
|
29 |
+
git tag -a "v$THEMEISLE_VERSION" -m "[AUTO] Release of $THEMEISLE_VERSION ";
|
30 |
+
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" --tags ;
|
31 |
+
sleep 5;
|
32 |
+
|
33 |
+
# Sends the api call for creating the release.
|
34 |
+
# We use this as the travis release provider does not offer any way
|
35 |
+
# to set the body of the release.
|
36 |
+
API_JSON='{"tag_name": "v'$THEMEISLE_VERSION'","target_commitish": "'$MASTER_BRANCH'","name": "v'$THEMEISLE_VERSION'","body": "'$CHANGES'","draft": false,"prerelease": false}';
|
37 |
+
curl -s --data "$API_JSON" "https://api.github.com/repos/$UPSTREAM_REPO/releases?access_token="$GITHUB_TOKEN > /dev/null;
|
38 |
+
fi
|
39 |
+
# Send update to the store
|
40 |
+
STORE_JSON='{"version": "'$THEMEISLE_VERSION'","id": "'$THEMEISLE_ID'","body": "'$CHANGES'"}';
|
41 |
+
curl -s -H "Content-Type: application/json" -H "x-themeisle-auth: $THEMEISLE_AUTH" --data "$STORE_JSON" "$STORE_URL/wp-json/ti-endpoint/v1/update_changelog_new/" > /dev/null
|
42 |
+
|
43 |
+
# Send data to demo server.
|
44 |
+
grunt sftp
|
45 |
+
|
46 |
+
# Upload to Wordpress SVN
|
47 |
+
if [ ! -z "$WPORG_PASS" ]; then
|
48 |
+
|
49 |
+
svn co -q "http://svn.wp-plugins.org/$THEMEISLE_REPO" svn
|
50 |
+
|
51 |
+
# Copy new content to svn trunk.
|
52 |
+
rsync -r -p --delete --exclude=".*" dist/* svn/trunk
|
53 |
+
|
54 |
+
# Create new SVN tag.
|
55 |
+
mkdir -p svn/tags/$THEMEISLE_VERSION
|
56 |
+
rsync -r -p dist/* svn/tags/$THEMEISLE_VERSION
|
57 |
+
# Add new files to SVN
|
58 |
+
svn stat svn | grep '^?' | awk '{print $2}' | xargs -I x svn add x@
|
59 |
+
# Remove deleted files from SVN
|
60 |
+
svn stat svn | grep '^!' | awk '{print $2}' | xargs -I x svn rm --force x@
|
61 |
+
|
62 |
+
svn stat svn
|
63 |
+
|
64 |
+
# Commit to SVN
|
65 |
+
svn commit svn --no-auth-cache -m "Release v$THEMEISLE_VERSION" --username $WPORG_USER --password $WPORG_PASS
|
66 |
+
# Remove svn dir.
|
67 |
+
rm -fR svn
|
68 |
+
|
69 |
+
fi
|
70 |
+
|
71 |
+
fi;
|
bin/install-dependencies.sh
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# We run this on PR or on push to MASTER_BRANCH.
|
4 |
+
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || ( [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$TRAVIS_REPO_SLUG" == "$UPSTREAM_REPO" ] && [ "$TRAVIS_BRANCH" == "$MASTER_BRANCH" ] && [ "$TRAVIS_PHP_VERSION" == "7.0" ] ) ; then
|
5 |
+
|
6 |
+
. $HOME/.nvm/nvm.sh
|
7 |
+
nvm install stable
|
8 |
+
nvm use stable
|
9 |
+
|
10 |
+
npm install
|
11 |
+
npm install grunt-cli -g
|
12 |
+
|
13 |
+
phpenv local 5.6
|
14 |
+
|
15 |
+
composer selfupdate 1.0.0 --no-interaction
|
16 |
+
composer install --no-interaction
|
17 |
+
phpenv local --unset
|
18 |
+
|
19 |
+
fi;
|
20 |
+
# We dont install PHPCS if is not a PR.
|
21 |
+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
22 |
+
|
23 |
+
# Install PHPCS.
|
24 |
+
pear install pear/PHP_CodeSniffer-2.8.1
|
25 |
+
|
26 |
+
# Install WPCS standards.
|
27 |
+
git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $HOME/wordpress-coding-standards
|
28 |
+
phpenv rehash
|
29 |
+
phpcs --config-set installed_paths $HOME/wordpress-coding-standards
|
30 |
+
phpenv rehash
|
31 |
+
|
32 |
+
# Install wordpress for testing.
|
33 |
+
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
34 |
+
export PATH="$HOME/.composer/vendor/bin:$PATH"
|
35 |
+
|
36 |
+
# Use phpunit 5.7 as WP dont support 6.
|
37 |
+
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
|
38 |
+
composer global require "phpunit/phpunit=5.7.*" ;
|
39 |
+
fi;
|
40 |
+
fi;
|
bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
|
4 |
+
if [ $# -lt 3 ]; then
|
5 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [force download]"
|
6 |
+
exit 1
|
7 |
+
fi
|
8 |
+
|
9 |
+
DB_NAME=$1
|
10 |
+
DB_USER=$2
|
11 |
+
DB_PASS=$3
|
12 |
+
DB_HOST=${4-localhost}
|
13 |
+
WP_VERSION=${5-latest}
|
14 |
+
FORCE=${6-false}
|
15 |
+
|
16 |
+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
17 |
+
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
|
18 |
+
|
19 |
+
download() {
|
20 |
+
if [ `which curl` ]; then
|
21 |
+
curl -s "$1" > "$2";
|
22 |
+
elif [ `which wget` ]; then
|
23 |
+
wget -nv -O "$2" "$1"
|
24 |
+
fi
|
25 |
+
}
|
26 |
+
|
27 |
+
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
|
28 |
+
WP_TESTS_TAG="tags/$WP_VERSION"
|
29 |
+
else
|
30 |
+
# http serves a single offer, whereas https serves multiple. we only want one
|
31 |
+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
|
32 |
+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
|
33 |
+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
|
34 |
+
if [[ -z "$LATEST_VERSION" ]]; then
|
35 |
+
echo "Latest WordPress version could not be found"
|
36 |
+
exit 1
|
37 |
+
fi
|
38 |
+
WP_TESTS_TAG="tags/$LATEST_VERSION"
|
39 |
+
fi
|
40 |
+
|
41 |
+
if [[ $WP_TESTS_TAG == *"beta"* ]]
|
42 |
+
then
|
43 |
+
WP_TESTS_TAG="trunk"
|
44 |
+
fi
|
45 |
+
|
46 |
+
set -ex
|
47 |
+
|
48 |
+
install_wp() {
|
49 |
+
if [ $FORCE == 'true' ]; then
|
50 |
+
rm -Rf $WP_CORE_DIR
|
51 |
+
fi
|
52 |
+
|
53 |
+
if [ -d $WP_CORE_DIR ]; then
|
54 |
+
return;
|
55 |
+
fi
|
56 |
+
|
57 |
+
mkdir -p $WP_CORE_DIR
|
58 |
+
|
59 |
+
if [ $WP_VERSION == 'latest' ]; then
|
60 |
+
local ARCHIVE_NAME='latest'
|
61 |
+
else
|
62 |
+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
63 |
+
fi
|
64 |
+
|
65 |
+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
|
66 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
67 |
+
|
68 |
+
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
69 |
+
}
|
70 |
+
|
71 |
+
install_test_suite() {
|
72 |
+
if [ $FORCE == 'true' ]; then
|
73 |
+
rm -Rf $WP_TESTS_DIR
|
74 |
+
fi
|
75 |
+
|
76 |
+
# portable in-place argument for both GNU sed and Mac OSX sed
|
77 |
+
if [[ $(uname -s) == 'Darwin' ]]; then
|
78 |
+
local ioption='-i .bak'
|
79 |
+
else
|
80 |
+
local ioption='-i'
|
81 |
+
fi
|
82 |
+
|
83 |
+
# set up testing suite if it doesn't yet exist
|
84 |
+
if [ ! -d $WP_TESTS_DIR ]; then
|
85 |
+
# set up testing suite
|
86 |
+
mkdir -p $WP_TESTS_DIR
|
87 |
+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
|
88 |
+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
|
89 |
+
fi
|
90 |
+
|
91 |
+
cd $WP_TESTS_DIR
|
92 |
+
|
93 |
+
if [ ! -f wp-tests-config.php ]; then
|
94 |
+
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
|
95 |
+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
|
96 |
+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
|
97 |
+
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
|
98 |
+
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
99 |
+
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
100 |
+
fi
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
install_db() {
|
105 |
+
# parse DB_HOST for port or socket references
|
106 |
+
local PARTS=(${DB_HOST//\:/ })
|
107 |
+
local DB_HOSTNAME=${PARTS[0]};
|
108 |
+
local DB_SOCK_OR_PORT=${PARTS[1]};
|
109 |
+
local EXTRA=""
|
110 |
+
|
111 |
+
if ! [ -z $DB_HOSTNAME ] ; then
|
112 |
+
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
|
113 |
+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
114 |
+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
115 |
+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
116 |
+
elif ! [ -z $DB_HOSTNAME ] ; then
|
117 |
+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
118 |
+
fi
|
119 |
+
fi
|
120 |
+
|
121 |
+
# create database
|
122 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
123 |
+
}
|
124 |
+
|
125 |
+
install_wp
|
126 |
+
install_test_suite
|
127 |
+
install_db
|
bin/prepare-deploy.sh
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
#We make sure we run this just at one before_deploy hook.
|
4 |
+
if ! [ $BEFORE_DEPLOY_RUN ] && [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then
|
5 |
+
|
6 |
+
echo " Preparing deploy. ";
|
7 |
+
|
8 |
+
# Flag the run.
|
9 |
+
export BEFORE_DEPLOY_RUN=1;
|
10 |
+
|
11 |
+
# Parse the name of the repo.
|
12 |
+
export THEMEISLE_REPO=$(node -pe "require('./package.json').name")
|
13 |
+
|
14 |
+
# Parse the version of the product.
|
15 |
+
|
16 |
+
export THEMEISLE_VERSION=$(node -pe "require('./package.json').version")
|
17 |
+
|
18 |
+
# Parse product category.
|
19 |
+
export THEMEISLE_CATEGORY=$(node -pe "require('./package.json').category")
|
20 |
+
|
21 |
+
export DEMO_THEMEISLE_PATH="/sites/demo.themeisle.com/wp-content/$THEMEISLE_CATEGORY/$THEMEISLE_REPO";
|
22 |
+
|
23 |
+
# Build changelog based on commit message description.
|
24 |
+
CHANGELOG="\n ### v$THEMEISLE_VERSION - "$(date +'%Y-%m-%d')" \n **Changes:** \n";
|
25 |
+
|
26 |
+
# Remove first line from the commit as is it used as commit title.
|
27 |
+
NORMALIZED_MESSAGE=$(sed "1d" <<< "$TRAVIS_COMMIT_MESSAGE");
|
28 |
+
|
29 |
+
# Save changes list in a sepparately variable as we use it in the release body.
|
30 |
+
export CHANGES="";
|
31 |
+
while read -r line; do
|
32 |
+
if ! [ -z $line ]; then
|
33 |
+
line=$(echo "${line//[$'\r\n']}");
|
34 |
+
export CHANGES=$CHANGES'- '$line'\n';
|
35 |
+
fi;
|
36 |
+
done <<< "$NORMALIZED_MESSAGE"
|
37 |
+
|
38 |
+
# Concat changes and changelog title and prepend to the changelog file.
|
39 |
+
|
40 |
+
CHANGELOG="$CHANGELOG $CHANGES";
|
41 |
+
echo -e "$CHANGELOG $(cat CHANGELOG.md)" > CHANGELOG.md
|
42 |
+
|
43 |
+
# Run the prepare deployment action
|
44 |
+
|
45 |
+
grunt deploy
|
46 |
+
fi;
|
css/front.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*
|
2 |
-
Version: 1.2.
|
3 |
*/
|
4 |
.pirate_forms_wrap .form_field_wrap {
|
5 |
margin-bottom: 20px;
|
1 |
/*
|
2 |
+
Version: 1.2.1
|
3 |
*/
|
4 |
.pirate_forms_wrap .form_field_wrap {
|
5 |
margin-bottom: 20px;
|
inc/settings.php
CHANGED
@@ -490,7 +490,12 @@ function pirate_forms_admin() {
|
|
490 |
|
491 |
<h4><?php esc_html_e( 'Are you enjoying Pirate Forms?', 'pirate-forms' ); ?></h4>
|
492 |
|
493 |
-
<p class="review-link"
|
|
|
|
|
|
|
|
|
|
|
494 |
|
495 |
<p><span class="dashicons dashicons-star-filled"></span><span
|
496 |
class="dashicons dashicons-star-filled"></span><span
|
@@ -499,7 +504,12 @@ function pirate_forms_admin() {
|
|
499 |
class="dashicons dashicons-star-filled"></span></p>
|
500 |
|
501 |
<p>
|
502 |
-
<small
|
|
|
|
|
|
|
|
|
|
|
503 |
</p>
|
504 |
</div>
|
505 |
|
490 |
|
491 |
<h4><?php esc_html_e( 'Are you enjoying Pirate Forms?', 'pirate-forms' ); ?></h4>
|
492 |
|
493 |
+
<p class="review-link">
|
494 |
+
<?php
|
495 |
+
/* translators: link to WordPress.org repo for PirateForms */
|
496 |
+
echo sprintf( esc_html__( 'Rate our plugin on %1$s WordPress.org %2$s. We\'d really appreciate it!', 'pirate-forms' ), '<a href="https://wordpress.org/support/view/plugin-reviews/pirate-forms" target="_blank" rel="nofollow"> ', '</a>' );
|
497 |
+
?>
|
498 |
+
</p>
|
499 |
|
500 |
<p><span class="dashicons dashicons-star-filled"></span><span
|
501 |
class="dashicons dashicons-star-filled"></span><span
|
504 |
class="dashicons dashicons-star-filled"></span></p>
|
505 |
|
506 |
<p>
|
507 |
+
<small>
|
508 |
+
<?php
|
509 |
+
/* translators: link to blog article about contact form plugins */
|
510 |
+
echo sprintf( esc_html__( 'If you want a more complex Contact Form Plugin please check %1$s this link %2$s.', 'pirate-forms' ), '<a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" target="_blank" >', '</a>' );
|
511 |
+
?>
|
512 |
+
</small>
|
513 |
</p>
|
514 |
</div>
|
515 |
|
inc/widget.php
CHANGED
@@ -16,7 +16,10 @@ class pirate_forms_contact_widget extends WP_Widget {
|
|
16 |
parent::__construct(
|
17 |
'pirate_forms_contact_widget',
|
18 |
__( 'Pirate Forms', 'pirate-forms' ),
|
19 |
-
array(
|
|
|
|
|
|
|
20 |
);
|
21 |
}
|
22 |
|
16 |
parent::__construct(
|
17 |
'pirate_forms_contact_widget',
|
18 |
__( 'Pirate Forms', 'pirate-forms' ),
|
19 |
+
array(
|
20 |
+
'classname' => __FUNCTION__,
|
21 |
+
'description' => __( 'Pirate Forms', 'pirate-forms' ),
|
22 |
+
)
|
23 |
);
|
24 |
}
|
25 |
|
pirate-forms.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Free & Simple Contact Form Plugin - PirateForms
|
4 |
Plugin URI: http://themeisle.com/plugins/pirate-forms/
|
5 |
Description: Easily creates a nice looking, simple contact form on your WP site.
|
6 |
-
Version: 1.2.
|
7 |
Author: Themeisle
|
8 |
Author URI: http://themeisle.com
|
9 |
Text Domain: pirate-forms
|
@@ -15,7 +15,7 @@ if ( ! function_exists( 'add_action' ) ) {
|
|
15 |
die( 'Nothing to do...' );
|
16 |
}
|
17 |
/* Important constants */
|
18 |
-
define( 'PIRATE_FORMS_VERSION', '1.2.
|
19 |
define( 'PIRATE_FORMS_URL', plugin_dir_url( __FILE__ ) );
|
20 |
define( 'PIRATE_FORMS_PATH', plugin_dir_path( __FILE__ ) );
|
21 |
/* Required helper functions */
|
@@ -345,10 +345,11 @@ function pirate_forms_init_uploads() {
|
|
345 |
return;
|
346 |
}
|
347 |
try {
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
352 |
fwrite( $handle, "Deny from all\n" );
|
353 |
fclose( $handle );
|
354 |
}
|
@@ -370,6 +371,10 @@ function pirate_forms_maybe_add_random_dir( $dir ) {
|
|
370 |
return $dir;
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
373 |
/**
|
374 |
* Process the incoming contact form data, if any
|
375 |
*/
|
@@ -396,8 +401,10 @@ function pirate_forms_process_contact() {
|
|
396 |
return false;
|
397 |
}
|
398 |
// Start the body of the contact email
|
399 |
-
$body = '
|
400 |
-
get_bloginfo( 'name' ) . ' (' . site_url() .
|
|
|
|
|
401 |
/**
|
402 |
******* Sanitize and validate name */
|
403 |
$pirate_forms_contact_name = isset( $_POST['pirate-forms-contact-name'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-name'] ) ) : '';
|
@@ -406,7 +413,7 @@ function pirate_forms_process_contact() {
|
|
406 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-name'] = pirate_forms_get_key( 'pirateformsopt_label_err_name' );
|
407 |
} // If not required and empty, leave it out
|
408 |
elseif ( ! empty( $pirate_forms_contact_name ) ) {
|
409 |
-
$body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_name' ) )
|
410 |
}
|
411 |
/**
|
412 |
***** Sanitize and validate email */
|
@@ -416,8 +423,7 @@ function pirate_forms_process_contact() {
|
|
416 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-email'] = pirate_forms_get_key( 'pirateformsopt_label_err_email' );
|
417 |
} // If not required and empty, leave it out
|
418 |
elseif ( ! empty( $pirate_forms_contact_email ) ) {
|
419 |
-
$body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_email' ) )
|
420 |
-
. ": $pirate_forms_contact_email \r";
|
421 |
}
|
422 |
/**
|
423 |
******* Sanitize and validate subject */
|
@@ -427,7 +433,7 @@ function pirate_forms_process_contact() {
|
|
427 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-subject'] = pirate_forms_get_key( 'pirateformsopt_label_err_subject' );
|
428 |
} // If not required and empty, leave it out
|
429 |
elseif ( ! empty( $pirate_forms_contact_subject ) ) {
|
430 |
-
$body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_subject' ) )
|
431 |
}
|
432 |
/**
|
433 |
******* Sanitize and validate message */
|
@@ -437,7 +443,7 @@ function pirate_forms_process_contact() {
|
|
437 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-message'] = pirate_forms_get_key( 'pirateformsopt_label_err_message' );
|
438 |
} // If not required and empty, leave it out
|
439 |
elseif ( ! empty( $pirate_forms_contact_message ) ) {
|
440 |
-
$body .= stripslashes( pirate_forms_get_key( 'pirateformsopt_label_message' ) )
|
441 |
}
|
442 |
/**
|
443 |
*********** Validate reCAPTCHA */
|
@@ -480,14 +486,15 @@ function pirate_forms_process_contact() {
|
|
480 |
}
|
481 |
// If valid and present, create a link to an IP search
|
482 |
if ( ! empty( $contact_ip ) ) {
|
483 |
-
$body .= __( 'IP address: ', 'pirate-forms' )
|
|
|
484 |
}
|
485 |
// Sanitize and prepare referrer;
|
486 |
if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
|
487 |
-
$body .= __( 'Came from: ', 'pirate-forms' )
|
488 |
}
|
489 |
// Show the page this contact form was submitted on
|
490 |
-
$body .= __( 'Sent from page: ', 'pirate-forms' )
|
491 |
// Check the blacklist
|
492 |
$blocked = pirate_forms_get_blacklist();
|
493 |
if ( ! empty( $blocked ) ) {
|
@@ -500,6 +507,8 @@ function pirate_forms_process_contact() {
|
|
500 |
return false;
|
501 |
}
|
502 |
}
|
|
|
|
|
503 |
// No errors? Go ahead and process the contact
|
504 |
if ( empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
|
505 |
$pirate_forms_options_tmp = get_option( 'pirate_forms_settings_array' );
|
@@ -537,7 +546,7 @@ function pirate_forms_process_contact() {
|
|
537 |
}
|
538 |
$send_from_name = $site_name;
|
539 |
// Sent an email notification to the correct address
|
540 |
-
$headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email
|
541 |
add_action( 'phpmailer_init', 'pirate_forms_phpmailer' );
|
542 |
/**
|
543 |
******* Validate Attachment */
|
@@ -575,7 +584,6 @@ function pirate_forms_process_contact() {
|
|
575 |
if ( false === move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
|
576 |
throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
|
577 |
}
|
578 |
-
// Make sure the uploaded file is only readable for the owner process
|
579 |
} catch ( Exception $ex ) {
|
580 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-general'] = $ex->getMessage();
|
581 |
}
|
@@ -584,6 +592,7 @@ function pirate_forms_process_contact() {
|
|
584 |
}
|
585 |
}
|
586 |
}
|
|
|
587 |
wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers, $attachments );
|
588 |
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
589 |
WP_Filesystem();
|
@@ -709,7 +718,9 @@ function pirate_forms_admin_css() {
|
|
709 |
) {
|
710 |
wp_enqueue_style( 'pirate_forms_admin_styles', PIRATE_FORMS_URL . 'css/wp-admin.css' );
|
711 |
wp_enqueue_script( 'pirate_forms_scripts_admin', plugins_url( 'js/scripts-admin.js', __FILE__ ), array( 'jquery' ) );
|
712 |
-
wp_localize_script( 'pirate_forms_scripts_admin', 'cwp_top_ajaxload', array(
|
|
|
|
|
713 |
}
|
714 |
}
|
715 |
|
3 |
Plugin Name: Free & Simple Contact Form Plugin - PirateForms
|
4 |
Plugin URI: http://themeisle.com/plugins/pirate-forms/
|
5 |
Description: Easily creates a nice looking, simple contact form on your WP site.
|
6 |
+
Version: 1.2.1
|
7 |
Author: Themeisle
|
8 |
Author URI: http://themeisle.com
|
9 |
Text Domain: pirate-forms
|
15 |
die( 'Nothing to do...' );
|
16 |
}
|
17 |
/* Important constants */
|
18 |
+
define( 'PIRATE_FORMS_VERSION', '1.2.1' );
|
19 |
define( 'PIRATE_FORMS_URL', plugin_dir_url( __FILE__ ) );
|
20 |
define( 'PIRATE_FORMS_PATH', plugin_dir_path( __FILE__ ) );
|
21 |
/* Required helper functions */
|
345 |
return;
|
346 |
}
|
347 |
try {
|
348 |
+
$handle = fopen( $htaccess_file, 'w' );
|
349 |
+
|
350 |
+
if ( ! $handle ) {
|
351 |
+
throw new Exception( 'File open failed.' );
|
352 |
+
} else {
|
353 |
fwrite( $handle, "Deny from all\n" );
|
354 |
fclose( $handle );
|
355 |
}
|
371 |
return $dir;
|
372 |
}
|
373 |
|
374 |
+
function pirate_forms_table_row( $key, $value ) {
|
375 |
+
return '<tr><th>' . $key . '</th><td>' . $value . '</td></tr>';
|
376 |
+
}
|
377 |
+
|
378 |
/**
|
379 |
* Process the incoming contact form data, if any
|
380 |
*/
|
401 |
return false;
|
402 |
}
|
403 |
// Start the body of the contact email
|
404 |
+
$body = '<h2>' . __( 'Contact form submission from', 'pirate-forms' ) . ' ' .
|
405 |
+
get_bloginfo( 'name' ) . ' (' . site_url() . ') </h2>';
|
406 |
+
|
407 |
+
$body .= '<table>';
|
408 |
/**
|
409 |
******* Sanitize and validate name */
|
410 |
$pirate_forms_contact_name = isset( $_POST['pirate-forms-contact-name'] ) ? sanitize_text_field( trim( $_POST['pirate-forms-contact-name'] ) ) : '';
|
413 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-name'] = pirate_forms_get_key( 'pirateformsopt_label_err_name' );
|
414 |
} // If not required and empty, leave it out
|
415 |
elseif ( ! empty( $pirate_forms_contact_name ) ) {
|
416 |
+
$body .= pirate_forms_table_row( stripslashes( pirate_forms_get_key( 'pirateformsopt_label_name' ) ), $pirate_forms_contact_name );
|
417 |
}
|
418 |
/**
|
419 |
***** Sanitize and validate email */
|
423 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-email'] = pirate_forms_get_key( 'pirateformsopt_label_err_email' );
|
424 |
} // If not required and empty, leave it out
|
425 |
elseif ( ! empty( $pirate_forms_contact_email ) ) {
|
426 |
+
$body .= pirate_forms_table_row( stripslashes( pirate_forms_get_key( 'pirateformsopt_label_email' ) ), $pirate_forms_contact_email );
|
|
|
427 |
}
|
428 |
/**
|
429 |
******* Sanitize and validate subject */
|
433 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-subject'] = pirate_forms_get_key( 'pirateformsopt_label_err_subject' );
|
434 |
} // If not required and empty, leave it out
|
435 |
elseif ( ! empty( $pirate_forms_contact_subject ) ) {
|
436 |
+
$body .= pirate_forms_table_row( stripslashes( pirate_forms_get_key( 'pirateformsopt_label_subject' ) ), $pirate_forms_contact_subject );
|
437 |
}
|
438 |
/**
|
439 |
******* Sanitize and validate message */
|
443 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-contact-message'] = pirate_forms_get_key( 'pirateformsopt_label_err_message' );
|
444 |
} // If not required and empty, leave it out
|
445 |
elseif ( ! empty( $pirate_forms_contact_message ) ) {
|
446 |
+
$body .= pirate_forms_table_row( stripslashes( pirate_forms_get_key( 'pirateformsopt_label_message' ) ), $pirate_forms_contact_message );
|
447 |
}
|
448 |
/**
|
449 |
*********** Validate reCAPTCHA */
|
486 |
}
|
487 |
// If valid and present, create a link to an IP search
|
488 |
if ( ! empty( $contact_ip ) ) {
|
489 |
+
$body .= pirate_forms_table_row( __( 'IP address: ', 'pirate-forms' ), $contact_ip );
|
490 |
+
$body .= pirate_forms_table_row( __( 'IP search:', 'pirate-forms' ), "http://whatismyipaddress.com/ip/$contact_ip" );
|
491 |
}
|
492 |
// Sanitize and prepare referrer;
|
493 |
if ( ! empty( $_POST['pirate-forms-contact-referrer'] ) ) {
|
494 |
+
$body .= pirate_forms_table_row( __( 'Came from: ', 'pirate-forms' ), sanitize_text_field( $_POST['pirate-forms-contact-referrer'] ) );
|
495 |
}
|
496 |
// Show the page this contact form was submitted on
|
497 |
+
$body .= pirate_forms_table_row( __( 'Sent from page: ', 'pirate-forms' ), get_permalink( get_the_id() ) );
|
498 |
// Check the blacklist
|
499 |
$blocked = pirate_forms_get_blacklist();
|
500 |
if ( ! empty( $blocked ) ) {
|
507 |
return false;
|
508 |
}
|
509 |
}
|
510 |
+
$body .= '</table>';
|
511 |
+
|
512 |
// No errors? Go ahead and process the contact
|
513 |
if ( empty( $_SESSION['pirate_forms_contact_errors'] ) ) {
|
514 |
$pirate_forms_options_tmp = get_option( 'pirate_forms_settings_array' );
|
546 |
}
|
547 |
$send_from_name = $site_name;
|
548 |
// Sent an email notification to the correct address
|
549 |
+
$headers = "From: $send_from_name <$send_from>\r\nReply-To: $pirate_forms_contact_name <$pirate_forms_contact_email>\r\nContent-type: text/html";
|
550 |
add_action( 'phpmailer_init', 'pirate_forms_phpmailer' );
|
551 |
/**
|
552 |
******* Validate Attachment */
|
584 |
if ( false === move_uploaded_file( $pirate_forms_attach_file['tmp_name'], $new_file ) ) {
|
585 |
throw new Exception( __( 'There was an unknown error uploading the file.', 'pirate-forms' ) );
|
586 |
}
|
|
|
587 |
} catch ( Exception $ex ) {
|
588 |
$_SESSION['pirate_forms_contact_errors']['pirate-forms-upload-failed-general'] = $ex->getMessage();
|
589 |
}
|
592 |
}
|
593 |
}
|
594 |
}
|
595 |
+
|
596 |
wp_mail( $site_recipients, 'Contact on ' . htmlspecialchars_decode( get_bloginfo( 'name' ) ), $body, $headers, $attachments );
|
597 |
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
598 |
WP_Filesystem();
|
718 |
) {
|
719 |
wp_enqueue_style( 'pirate_forms_admin_styles', PIRATE_FORMS_URL . 'css/wp-admin.css' );
|
720 |
wp_enqueue_script( 'pirate_forms_scripts_admin', plugins_url( 'js/scripts-admin.js', __FILE__ ), array( 'jquery' ) );
|
721 |
+
wp_localize_script( 'pirate_forms_scripts_admin', 'cwp_top_ajaxload', array(
|
722 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
723 |
+
) );
|
724 |
}
|
725 |
}
|
726 |
|
tests/bootstrap.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHPUnit bootstrap file
|
4 |
+
*
|
5 |
+
* @package Revive_Network
|
6 |
+
*/
|
7 |
+
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
8 |
+
if ( ! $_tests_dir ) {
|
9 |
+
$_tests_dir = '/tmp/wordpress-tests-lib';
|
10 |
+
}
|
11 |
+
/**
|
12 |
+
* The path to the main file of the plugin to test.
|
13 |
+
*/
|
14 |
+
define( 'WP_USE_THEMES', false );
|
15 |
+
define( 'WP_TESTS_FORCE_KNOWN_BUGS', true );
|
16 |
+
// Give access to tests_add_filter() function.
|
17 |
+
require_once $_tests_dir . '/includes/functions.php';
|
18 |
+
/**
|
19 |
+
* Manually load the plugin being tested.
|
20 |
+
*/
|
21 |
+
function _manually_load_plugin() {
|
22 |
+
require dirname( dirname( __FILE__ ) ) . '/pirate-forms.php';
|
23 |
+
}
|
24 |
+
|
25 |
+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
26 |
+
define( 'REVIVE_NETWORK_ENABLE_LOG', false );
|
27 |
+
define( 'REVIVE_NETWORK_PREVENT_SHARING', true );
|
28 |
+
// Start up the WP testing environment.
|
29 |
+
require $_tests_dir . '/includes/bootstrap.php';
|
30 |
+
activate_plugin( 'revive-network/pirate-forms.php' );
|
31 |
+
global $current_user;
|
32 |
+
$current_user = new WP_User( 1 );
|
33 |
+
$current_user->set_role( 'administrator' );
|
34 |
+
wp_update_user( array( 'ID' => 1, 'first_name' => 'Admin', 'last_name' => 'User' ) );
|
tests/test-pirate-forms.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sample class for PHPUnit.
|
4 |
+
*
|
5 |
+
* @package nivo-slider
|
6 |
+
* @subpackage Tests
|
7 |
+
* @copyright Copyright (c) 2017, Marius Cristea
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 3.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Sample test class.
|
14 |
+
*/
|
15 |
+
class Test_Pirate_Forms extends WP_UnitTestCase {
|
16 |
+
|
17 |
+
public function test_generic() {
|
18 |
+
$this->assertTrue(true);
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|