Skip to content

Commit 0655e7f

Browse files
committed
init
0 parents  commit 0655e7f

10 files changed

Lines changed: 298 additions & 0 deletions

File tree

.distignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.git
2+
/.github
3+
/.wordpress-org
4+
5+
.distignore
6+
.gitignore
7+
.gitattributes

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Directories
2+
/.wordpress-org export-ignore
3+
/.github export-ignore
4+
5+
# Files
6+
/.editorconfig export-ignore
7+
/.gitattributes export-ignore
8+
/.gitignore export-ignore
9+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://github.com/10up/action-wordpress-plugin-asset-update
2+
3+
# This Action commits any readme and WordPress.org-specific assets changes in your specified branch to the
4+
# WordPress.org plugin repository if no other changes have been made since the last deployment to WordPress.org.
5+
# This is useful for updating things like screenshots or Tested up to separately from functional changes, provided
6+
# your Git branching methodology avoids changing anything else in the specified branch between functional releases.
7+
8+
name: Plugin asset/readme update
9+
on:
10+
push:
11+
branches:
12+
- master
13+
jobs:
14+
master:
15+
name: Update plugin and assets
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@master
19+
- name: WordPress.org plugin asset/readme update
20+
uses: 10up/action-wordpress-plugin-asset-update@master
21+
env:
22+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} # Set in repo -> Settings -> Secrets
23+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} # Set in repo -> Settings -> Secrets
24+
README_NAME: README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# https://github.com/10up/action-wordpress-plugin-deploy
2+
3+
# This Action commits the contents of your Git tag to the WordPress.org plugin repository using the same tag name.
4+
# It can exclude files as defined in either .distignore or .gitattributes, and moves anything from a .wordpress-org
5+
# subdirectory to the top-level assets directory in Subversion (plugin banners, icons, and screenshots).
6+
7+
name: Publish plugin to WordPress.org
8+
on:
9+
push:
10+
tags:
11+
- "*"
12+
jobs:
13+
tag:
14+
name: New tag
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@master
18+
- name: WordPress Plugin Deploy
19+
uses: 10up/action-wordpress-plugin-deploy@master
20+
env:
21+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
22+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
23+
SLUG: no-login # Change this

.gitignore

Whitespace-only changes.

.wordpress-org/banner-772x250.png

285 KB
Loading

fartscroll.js

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fartscroll.php

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
/**
3+
* Plugin Name: FartScroll
4+
* Plugin URI: http://planetozh.com/blog/my-projects/wordpress-plugin-fart-scroll-theonion/
5+
* GitHub Plugin URI: https://github.com/ozh/fartscroll
6+
* Description: "You want fart noises as you scroll? We've got you covered." A WordPress implementation of TheOnion's <a href="http://theonion.github.io/fartscroll.js/">Fartscroll.js</a> elegant piece of software
7+
* Version: 1.0.1
8+
* Requires at least: 3.0
9+
* Requires PHP: 5.6
10+
* Author: Ozh & TheOnion
11+
* Author URI: http://ozh.org/
12+
*/
13+
14+
15+
/****************** Public stuff */
16+
17+
// Add JS to pages of the blog
18+
add_action( 'template_redirect', 'fartscroll_add_script' );
19+
function fartscroll_add_script() {
20+
$options = get_option( 'fartscroll_options' );
21+
$fart_chance = ( isset( $options['fart_chance'] ) ? $options['fart_chance'] : 100 );
22+
if( mt_rand( 0, 100 ) <= $fart_chance ) {
23+
wp_enqueue_script( 'fartscroll', plugin_dir_url( __FILE__) . 'fartscroll.js' );
24+
add_action( 'wp_footer', 'fartscroll_add_footer' );
25+
}
26+
}
27+
28+
// Add JS to footer
29+
function fartscroll_add_footer() {
30+
$options = get_option( 'fartscroll_options' );
31+
$fart_scroll = ( isset( $options['fart_scroll'] ) ? $options['fart_scroll'] : 800 );
32+
echo <<<FART
33+
<script type="text/javascript">
34+
fartscroll( $fart_scroll );
35+
</script>
36+
37+
FART;
38+
}
39+
40+
41+
/****************** Admin stuff */
42+
43+
// Add a menu for our option page
44+
add_action('admin_menu', 'fartscroll_add_page');
45+
function fartscroll_add_page() {
46+
add_options_page( 'Fartscroll', 'Fartscroll', 'manage_options', 'fartscroll', 'fartscroll_option_page' );
47+
}
48+
49+
// Draw the option page
50+
function fartscroll_option_page() {
51+
?>
52+
<div class="wrap">
53+
<?php screen_icon(); ?>
54+
<h2>Fartscroll. Pfffrrrtf.</h2>
55+
<form action="options.php" method="post">
56+
<?php settings_fields('fartscroll_options'); ?>
57+
<?php do_settings_sections('fartscroll'); ?>
58+
<input name="Submit" type="submit" value="Save Changes" />
59+
</form>
60+
</div>
61+
<?php
62+
}
63+
64+
// Register and define the settings
65+
add_action('admin_init', 'fartscroll_admin_init');
66+
function fartscroll_admin_init(){
67+
register_setting(
68+
'fartscroll_options',
69+
'fartscroll_options',
70+
'fartscroll_validate_options'
71+
);
72+
add_settings_section(
73+
'fartscroll_main',
74+
'Fartscroll Settings',
75+
'fartscroll_section_text',
76+
'fartscroll'
77+
);
78+
add_settings_field(
79+
'fartscroll_fart_scroll',
80+
'Scrolling',
81+
'fartscroll_setting_input_scroll',
82+
'fartscroll',
83+
'fartscroll_main'
84+
);
85+
add_settings_field(
86+
'fartscroll_fart_chance',
87+
'Probability',
88+
'fartscroll_setting_input_chance',
89+
'fartscroll',
90+
'fartscroll_main'
91+
);
92+
}
93+
94+
// Draw the section header
95+
function fartscroll_section_text() {
96+
echo '<p>Configure how much and how often you want farts on scrolls.</p>';
97+
}
98+
99+
// Display and fill the form field
100+
function fartscroll_setting_input_scroll() {
101+
// get option 'fart_scroll' value from the database
102+
$options = get_option( 'fartscroll_options' );
103+
$fart_scroll = ( isset( $options['fart_scroll'] ) ? $options['fart_scroll'] : 800 );
104+
// echo the field
105+
echo "<input id='fart_scroll' name='fartscroll_options[fart_scroll]' type='text' value='$fart_scroll' />";
106+
echo "<br/>How many pixels scrolled to emit a fart ? (default: 800)";
107+
}
108+
109+
// Display and fill the form field
110+
function fartscroll_setting_input_chance() {
111+
// get option 'fart_chance' value from the database
112+
$options = get_option( 'fartscroll_options' );
113+
$fart_chance = ( isset( $options['fart_chance'] ) ? $options['fart_chance'] : 100 );
114+
// echo the field
115+
echo "<input id='fart_chance' name='fartscroll_options[fart_chance]' type='text' value='$fart_chance' />";
116+
echo "<br/>Probability, in percent, that the script is loaded on a page. 100 = all pages, 10 = 1 page out of ten (default: 100)";
117+
}
118+
119+
// Validate user input
120+
function fartscroll_validate_options( $input ) {
121+
$valid = array();
122+
$valid['fart_scroll'] = intval( $input['fart_scroll'] );
123+
$valid['fart_chance'] = min( absint( $input['fart_chance'] ), 100 );
124+
125+
return $valid;
126+
}
127+
128+
// Settings link in plugin management screen
129+
function fartscroll_settings_link($actions, $file) {
130+
if( false !== strpos($file, 'fartscroll' ) )
131+
$actions['settings'] = '<a href="options-general.php?page=fartscroll">Fart settings</a>';
132+
return $actions;
133+
}
134+
add_filter( 'plugin_action_links', 'fartscroll_settings_link', 2, 2 );
135+

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Fartscroll
2+
3+
"You want fart noises as you scroll? We've got you covered."
4+
5+
A WordPress implementation of TheOnion's [Fartscroll.js](http://theonion.github.io/fartscroll.js/) most elegant piece of software

readme.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== Fartscroll ===
2+
Tags: fart, scroll, fartscroll, theonion, smell, prank, ozh
3+
Donate link: http://planetozh.com/exit/donate
4+
Requires at least: 3.0
5+
Tested up to: 5.4.1
6+
Requires PHP: 5.6
7+
Stable tag: trunk
8+
Contributors: ozh
9+
10+
You want fart noises as you scroll? We've got you covered
11+
12+
== Description ==
13+
14+
"You want fart noises as you scroll? We've got you covered."
15+
16+
A WordPress implementation of TheOnion's [Fartscroll.js](http://theonion.github.io/fartscroll.js/) most elegant piece of software
17+
18+
== Installation ==
19+
20+
1. Unzip & upload the plugin directory inside your `/wp-content/plugins/` directory
21+
1. Activate the plugin through the 'Plugins' menu in WordPress
22+
1. Scroll blog pages

0 commit comments

Comments
 (0)