Code Duplication    Length = 16-16 lines in 2 locations

modules/videopress/class.videopress-cli.php 2 locations

@@ 125-140 (lines=16) @@
122
		 *
123
		 * wp videopress activate_cron cleanup
124
		 */
125
		public function activate_cron( $args ) {
126
127
			if ( ! isset( $args[0] ) ) {
128
				WP_CLI::error( __( 'You need to provide the name of the cronjob to schedule.', 'jetpack' ) );
129
			}
130
131
			$scheduler = VideoPress_Scheduler::init();
132
133
			if ( ! $scheduler->is_cron_valid( $args[0] ) ) {
134
				return WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
135
			}
136
137
			$scheduler->activate_cron( $args[0] );
138
139
			WP_CLI::success( sprintf( __( 'The cron named `%s` was scheduled.', 'jetpack' ), $args[0] ) );
140
		}
141
142
		/**
143
		 * Actives the given cron job
@@ 153-168 (lines=16) @@
150
		 *
151
		 * wp videopress deactivate_cron cleanup
152
		 */
153
		public function deactivate_cron( $args ) {
154
155
			if ( ! isset( $args[0] ) ) {
156
				WP_CLI::error( __( 'You need to provide the name of the cronjob to schedule.', 'jetpack' ) );
157
			}
158
159
			$scheduler = VideoPress_Scheduler::init();
160
161
			if ( ! $scheduler->is_cron_valid( $args[0] ) ) {
162
				return WP_CLI::error( sprintf( __( 'There is no cron named %s.', 'jetpack' ), $args[0] ) );
163
			}
164
165
			$scheduler->deactivate_cron( $args[0] );
166
167
			WP_CLI::success( sprintf( __( 'The cron named `%s` was removed from the schedule.', 'jetpack' ), $args[0] ) );
168
		}
169
	}
170
171
	WP_CLI::add_command( 'videopress', 'VideoPress_CLI' );